Interface IWsMessenger<T>
Interface of a WebSocket messenger.
public interface IWsMessenger<T>
Type Parameters
T
- Extension Methods
Fields
DFLT_SCOPE
Default scope.
public const string DFLT_SCOPE = "_"
Field Value
Methods
Publish(T, string?)
Publish message to optional scope
Task Publish(T message, string? scope = "_")
Parameters
messageTscopestring
Returns
Remarks
Any messages published to a scope that has no registered connections is ignored.
RegisterConnection(WebSocket, CancellationToken, string?, Action<ReadOnlySequence<byte>, string>?)
Register socket connection with ctk
and optional scope and also optional msgReceiver
Task RegisterConnection(WebSocket socket, CancellationToken ctk, string? scope = null, Action<ReadOnlySequence<byte>, string>? msgReceiver = null)
Parameters
socketWebSocketctkCancellationTokenscopestringmsgReceiverAction<ReadOnlySequence<byte>, string>
Returns
RegisterConnection(WebSocket, CancellationToken, string?, Action<byte[], string>?)
Register socket connection with ctk
and optional scope and also optional msgReceiver
[Obsolete("Use overload taking Action<ReadOnlyMemory<byte>, string>? msgReceiver", false)]
Task RegisterConnection(WebSocket socket, CancellationToken ctk, string? scope, Action<byte[], string>? msgReceiver)
Parameters
Returns
Send(T, Task)
Send message to WS connection identified with sockTsk returned from RegisterConnection(WebSocket, CancellationToken, string?, Action<byte[], string>?)
Task Send(T message, Task sockTsk)
Parameters
messageTsockTskTask
Returns
Remarks
In contrast to Publish(T, string?) this sends only to the WS connewction identified with sockTsk.
Events
DroppedScope
Event fired on connection dropped.
event Action<string>? DroppedScope