Class HttpListenerWebSocket

Namespace
Cratis.Arc.Http
Assembly
Cratis.Arc.Core.dll

Implementation of IWebSocket for HttpListener WebSockets.

public class HttpListenerWebSocket : IWebSocket, IDisposable
Inheritance
HttpListenerWebSocket
Implements
Inherited Members
Extension Methods

Constructors

HttpListenerWebSocket(WebSocket)

Implementation of IWebSocket for HttpListener WebSockets.

public HttpListenerWebSocket(WebSocket webSocket)

Parameters

webSocket WebSocket

The underlying WebSocket.

Properties

State

Gets the current state of the WebSocket connection.

public WebSocketState State { get; }

Property Value

WebSocketState

Methods

Close(WebSocketCloseStatus, string?, CancellationToken)

Closes the WebSocket connection.

public Task Close(WebSocketCloseStatus closeStatus, string? statusDescription, CancellationToken cancellationToken)

Parameters

closeStatus WebSocketCloseStatus

The close status.

statusDescription string

The status description.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

A task representing the async operation.

Dispose()

public void Dispose()

Receive(ArraySegment<byte>, CancellationToken)

Receives data from the WebSocket connection.

public Task<WebSocketReceiveResult> Receive(ArraySegment<byte> buffer, CancellationToken cancellationToken)

Parameters

buffer ArraySegment<byte>

The buffer to receive data into.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<WebSocketReceiveResult>

The result of the receive operation.

Send(ArraySegment<byte>, WebSocketMessageType, bool, CancellationToken)

Sends data over the WebSocket connection.

public Task Send(ArraySegment<byte> buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancellationToken)

Parameters

buffer ArraySegment<byte>

The data to send.

messageType WebSocketMessageType

The type of message.

endOfMessage bool

Whether this is the end of the message.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

A task representing the async operation.