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
Properties
State
Gets the current state of the WebSocket connection.
public WebSocketState State { get; }
Property Value
Methods
Close(WebSocketCloseStatus, string?, CancellationToken)
Closes the WebSocket connection.
public 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.
Dispose()
public void Dispose()
Receive(ArraySegment<byte>, CancellationToken)
Receives data from the WebSocket connection.
public 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.
public 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.