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
Methods
Close(WebSocketCloseStatus, string?, CancellationToken)
Closes the WebSocket connection.
Task Close(WebSocketCloseStatus closeStatus, string? statusDescription, CancellationToken cancellationToken)
Parameters
closeStatusWebSocketCloseStatusThe close status.
statusDescriptionstringThe status description.
cancellationTokenCancellationTokenCancellation 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
bufferArraySegment<byte>The buffer to receive data into.
cancellationTokenCancellationTokenCancellation 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
bufferArraySegment<byte>The data to send.
messageTypeWebSocketMessageTypeThe type of message.
endOfMessageboolWhether this is the end of the message.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task
A task representing the async operation.