Method ReceiveMessageAsync
ReceiveMessageAsync(CancellationToken)
Receives a message from the WebSocket endpoint asynchronously.
public ValueTask<WebSocketMessage?> ReceiveMessageAsync(CancellationToken cancellation = default)
Parameters
cancellation
CancellationTokenThe CancellationToken to use for cancellation.
Returns
- ValueTask<WebSocketMessage>
A ValueTask<TResult> that represents the asynchronous receive operation, which returns a WebSocketMessage if a message is received; otherwise,
null
.
ReceiveMessageAsync(TimeSpan)
Receives a message from the WebSocket endpoint asynchronously with a specified timeout.
public ValueTask<WebSocketMessage?> ReceiveMessageAsync(TimeSpan timeout)
Parameters
timeout
TimeSpanThe time to wait for a message before timing out.
Returns
- ValueTask<WebSocketMessage>
A ValueTask<TResult> that represents the asynchronous receive operation, which returns a WebSocketMessage if a message is received; otherwise,
null
.
ReceiveMessageAsync()
Receives a message from the WebSocket endpoint asynchronously with a default timeout of 30 seconds.
public ValueTask<WebSocketMessage?> ReceiveMessageAsync()
Returns
- ValueTask<WebSocketMessage>
A ValueTask<TResult> that represents the asynchronous receive operation, which returns a WebSocketMessage if a message is received; otherwise,
null
.