Interface IWebSocketConnectionStore
- Namespace
- Virtufin.WebSocketManager.Services
- Assembly
- Virtufin.WebSocketManager.dll
Interface for WebSocket connection storage.
public interface IWebSocketConnectionStore
Methods
ClearAllConnectionsAsync(CancellationToken)
Removes all WebSocket connections.
Task ClearAllConnectionsAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
CreateConnectionAsync(string, bool, CancellationToken)
Creates a new WebSocket connection entry.
ValueTask<WebSocketConnection> CreateConnectionAsync(string url, bool autoReconnect, CancellationToken cancellationToken = default)
Parameters
urlstringautoReconnectboolcancellationTokenCancellationToken
Returns
GetAllConnectionsAsync(CancellationToken)
Gets all WebSocket connections.
Task<IEnumerable<WebSocketConnection>> GetAllConnectionsAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
GetConnectionAsync(string, CancellationToken)
Gets a WebSocket connection by its ID.
Task<WebSocketConnection?> GetConnectionAsync(string id, CancellationToken cancellationToken = default)
Parameters
idstringcancellationTokenCancellationToken
Returns
GetConnectionById(string)
Synchronous lookup of a local connection by ID (in-memory only). Returns null for connections owned by other instances.
WebSocketConnection? GetConnectionById(string id)
Parameters
idstring
Returns
GetLocalConnections()
Snapshot of connections owned by this instance (in-memory only). Used by ConnectionHeartbeatService to refresh state-store TTLs without depending on send/publish traffic.
IReadOnlyCollection<WebSocketConnection> GetLocalConnections()
Returns
ReclaimAsync(string, CancellationToken)
Re-stamps ownership of a connection last known to be owned by
another (now unreachable) instance to this one, persists it, and
registers it in this instance's local, in-memory view -- unlike
GetConnectionAsync(string, CancellationToken), which is local-only and would
otherwise never see a connection this instance didn't originally
create. Returns the reclaimed connection (caller is responsible for
actually re-establishing the socket if desired), or null if
no persisted record exists for id.
Task<WebSocketConnection?> ReclaimAsync(string id, CancellationToken cancellationToken = default)
Parameters
idstringcancellationTokenCancellationToken
Returns
RemoveConnectionAsync(string, CancellationToken)
Removes a WebSocket connection by its ID.
Task RemoveConnectionAsync(string id, CancellationToken cancellationToken = default)
Parameters
idstringcancellationTokenCancellationToken
Returns
TouchAsync(string, CancellationToken)
Refreshes the state-store TTL on the connection record without changing its payload. Called after a successful Send to keep an idle but live socket from being garbage-collected.
Task TouchAsync(string id, CancellationToken cancellationToken = default)
Parameters
idstringcancellationTokenCancellationToken
Returns
UpdateConnectionAsync(WebSocketConnection, CancellationToken)
Updates an existing WebSocket connection.
Task UpdateConnectionAsync(WebSocketConnection connection, CancellationToken cancellationToken = default)
Parameters
connectionWebSocketConnectioncancellationTokenCancellationToken