Table of Contents

Interface IWsMessenger<T>

Namespace
Tlabs.Msg
Assembly
Tlabs.SrvBase.dll

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

string

Methods

Publish(T, string?)

Publish message to optional scope

Task Publish(T message, string? scope = "_")

Parameters

message T
scope string

Returns

Task

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

socket WebSocket
ctk CancellationToken
scope string
msgReceiver Action<ReadOnlySequence<byte>, string>

Returns

Task

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

socket WebSocket
ctk CancellationToken
scope string
msgReceiver Action<byte[], string>

Returns

Task

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

message T
sockTsk Task

Returns

Task

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

Event Type

Action<string>