Table of Contents

Interface IWebSocketClientFactory

Namespace
Alis.Core.Network
Assembly
Alis.dll

Web socket client factory used to open web socket client connections

public interface IWebSocketClientFactory

Methods

ConnectAsync(Uri, CancellationToken)

Connect with default options

Task<WebSocket> ConnectAsync(Uri uri, CancellationToken token = default)

Parameters

uri Uri

The WebSocket uri to connect to (e.g. ws://example.com or wss://example.com for SSL)

token CancellationToken

The optional cancellation token

Returns

Task<WebSocket>

A connected web socket instance

ConnectAsync(Uri, WebSocketClientOptions, CancellationToken)

Connect with options specified

Task<WebSocket> ConnectAsync(Uri uri, WebSocketClientOptions options, CancellationToken token = default)

Parameters

uri Uri

The WebSocket uri to connect to (e.g. ws://example.com or wss://example.com for SSL)

options WebSocketClientOptions

The WebSocket client options

token CancellationToken

The optional cancellation token

Returns

Task<WebSocket>

A connected web socket instance

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

responseStream Stream

The full duplex response stream from the server

secWebSocketKey string

The secWebSocketKey you used in the handshake request

options WebSocketClientOptions

The WebSocket client options

token CancellationToken

The optional cancellation token

Returns

Task<WebSocket>