Interface IWebSocketClientFactory
- Namespace
- Alis.Core.Network
- Assembly
- Alis.dll
Web socket client factory used to open web socket client connections
public interface IWebSocketClientFactoryMethods
ConnectAsync(Uri, CancellationToken)
Connect with default options
Task<WebSocket> ConnectAsync(Uri uri, CancellationToken token = default)Parameters
uriUri-
The WebSocket uri to connect to (e.g. ws://example.com or wss://example.com for SSL)
tokenCancellationToken-
The optional cancellation token
Returns
ConnectAsync(Uri, WebSocketClientOptions, CancellationToken)
Connect with options specified
Task<WebSocket> ConnectAsync(Uri uri, WebSocketClientOptions options, CancellationToken token = default)Parameters
uriUri-
The WebSocket uri to connect to (e.g. ws://example.com or wss://example.com for SSL)
optionsWebSocketClientOptions-
The WebSocket client options
tokenCancellationToken-
The optional cancellation token
Returns
ConnectAsync(Stream, string, WebSocketClientOptions, CancellationToken)
Connect with a stream that has already been opened and HTTP websocket upgrade request sent This function will check the handshake response from the server and proceed if successful Use this function if you have specific requirements to open a conenction like using special http headers and cookies You will have to build your own HTTP websocket upgrade request You may not even choose to use TCP/IP and this function will allow you to do that
Task<WebSocket> ConnectAsync(Stream responseStream, string secWebSocketKey, WebSocketClientOptions options, CancellationToken token = default)Parameters
responseStreamStream-
The full duplex response stream from the server
secWebSocketKeystring-
The secWebSocketKey you used in the handshake request
optionsWebSocketClientOptions-
The WebSocket client options
tokenCancellationToken-
The optional cancellation token