Table of Contents

Interface IWebSocketServerFactory

Namespace
Alis.Core.Network
Assembly
Alis.dll

Web socket server factory used to open web socket server connections

public interface IWebSocketServerFactory

Methods

AcceptWebSocketAsync(WebSocketHttpContext, CancellationToken)

Accept web socket with default options Call ReadHttpHeaderFromStreamAsync first to get WebSocketHttpContext

Task<WebSocket> AcceptWebSocketAsync(WebSocketHttpContext context, CancellationToken token = default)

Parameters

context WebSocketHttpContext

The http context used to initiate this web socket request

token CancellationToken

The optional cancellation token

Returns

Task<WebSocket>

A connected web socket

AcceptWebSocketAsync(WebSocketHttpContext, WebSocketServerOptions, CancellationToken)

Accept web socket with options specified Call ReadHttpHeaderFromStreamAsync first to get WebSocketHttpContext

Task<WebSocket> AcceptWebSocketAsync(WebSocketHttpContext context, WebSocketServerOptions options, CancellationToken token = default)

Parameters

context WebSocketHttpContext

The http context used to initiate this web socket request

options WebSocketServerOptions

The web socket options

token CancellationToken

The optional cancellation token

Returns

Task<WebSocket>

A connected web socket

ReadHttpHeaderFromStreamAsync(Stream, CancellationToken)

Reads a http header information from a stream and decodes the parts relating to the WebSocket protocot upgrade

Task<WebSocketHttpContext> ReadHttpHeaderFromStreamAsync(Stream stream, CancellationToken token = default)

Parameters

stream Stream

The network stream

token CancellationToken

The optional cancellation token

Returns

Task<WebSocketHttpContext>

Http data read from the stream