Interface IWebSocket

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

Represents an abstraction for WebSocket communication.

public interface IWebSocket : IDisposable
Inherited Members
Extension Methods

Properties

State

Gets the current state of the WebSocket connection.

WebSocketState State { get; }

Property Value

WebSocketState

Methods

Close(WebSocketCloseStatus, string?, CancellationToken)

Closes the WebSocket connection.

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.

Receive(ArraySegment<byte>, CancellationToken)

Receives data from the WebSocket connection.

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.

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.