Table of Contents

Interface IWebSocketService

Namespace
Virtufin.WebSocketManager.Services
Assembly
Virtufin.WebSocketManager.dll
public interface IWebSocketService

Methods

ConnectAsync(string, string, bool, CancellationToken)

Opens a new WebSocket connection under id -- minted by the caller (WebSocketManagerGrpcService.Connect), which activates the owning WebSocketConnectionActor for it before this ever runs, rather than generated in here.

Task<WebSocketConnection> ConnectAsync(string id, string url, bool autoReconnect, CancellationToken cancellationToken = default)

Parameters

id string
url string
autoReconnect bool
cancellationToken CancellationToken

Returns

Task<WebSocketConnection>

DisconnectAsync(string, CancellationToken)

Task DisconnectAsync(string id, CancellationToken cancellationToken = default)

Parameters

id string
cancellationToken CancellationToken

Returns

Task

EnsureLocalAsync(string, CancellationToken)

Self-heals a connection whose actor was just activated on this instance without ever opening its socket here -- a genuine failover/rebalance of an already-connected id (the previous owner gone, or this actor freshly reactivated after an idle deactivation), not a fresh ConnectAsync(string, string, bool, CancellationToken) (which registers the connection locally itself, so this is always a no-op right after one of those). Reconnects immediately if auto-reconnect was set. A no-op if the connection is already local, or if there's no persisted record for it at all.

Task EnsureLocalAsync(string id, CancellationToken cancellationToken = default)

Parameters

id string
cancellationToken CancellationToken

Returns

Task

GetTag(string, string)

string? GetTag(string id, string key)

Parameters

id string
key string

Returns

string

GetTags(string)

IReadOnlyDictionary<string, string> GetTags(string id)

Parameters

id string

Returns

IReadOnlyDictionary<string, string>

ListConnectionsAsync(CancellationToken)

Task<IEnumerable<WebSocketConnection>> ListConnectionsAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task<IEnumerable<WebSocketConnection>>

SendAsync(string, byte[], int, string, CancellationToken)

Task<byte[]> SendAsync(string id, byte[] message, int timeoutMs, string contentType, CancellationToken cancellationToken = default)

Parameters

id string
message byte[]
timeoutMs int
contentType string
cancellationToken CancellationToken

Returns

Task<byte[]>

SendRawAsync(string, byte[], string, CancellationToken)

Task SendRawAsync(string id, byte[] message, string contentType, CancellationToken cancellationToken = default)

Parameters

id string
message byte[]
contentType string
cancellationToken CancellationToken

Returns

Task

SetTagAsync(string, string, string, CancellationToken)

Persists the tag via UpdateConnectionAsync(WebSocketConnection, CancellationToken) so it survives to List()'s cross-instance view (that of a connection owned by another instance comes from the persisted store, not this instance's own in-memory copy) -- unlike the pre-0.4.2 version, which only ever mutated the in-memory Tags dictionary. GetTag(string, string)/GetTags(string) are unaffected by this either way: both RPCs already route through the actor to the true owner, which always has the live in-memory value regardless of persistence.

Task SetTagAsync(string id, string key, string value, CancellationToken cancellationToken = default)

Parameters

id string
key string
value string
cancellationToken CancellationToken

Returns

Task

SetTagsAsync(string, IDictionary<string, string>, CancellationToken)

Task SetTagsAsync(string id, IDictionary<string, string> tags, CancellationToken cancellationToken = default)

Parameters

id string
tags IDictionary<string, string>
cancellationToken CancellationToken

Returns

Task

StartPublishAsync(string, string, CancellationToken)

Task StartPublishAsync(string id, string topic, CancellationToken cancellationToken = default)

Parameters

id string
topic string
cancellationToken CancellationToken

Returns

Task

StopPublishAsync(string, CancellationToken)

Task StopPublishAsync(string id, CancellationToken cancellationToken = default)

Parameters

id string
cancellationToken CancellationToken

Returns

Task