Method SendAsync
SendAsync(string, CancellationToken)
Sends an asynchronous text message to the WebSocket endpoint.
public ValueTask<bool> SendAsync(string message, CancellationToken cancellation = default)
Parameters
message
stringThe text message to send.
cancellation
CancellationTokenThe CancellationToken to use for cancellation.
Returns
- ValueTask<bool>
A ValueTask<TResult> that represents the asynchronous send operation, which returns true if the message was sent successfully; otherwise, false.
SendAsync(ReadOnlyMemory<byte>, CancellationToken)
Sends an asynchronous binary message to the WebSocket endpoint.
public ValueTask<bool> SendAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellation = default)
Parameters
buffer
ReadOnlyMemory<byte>The binary data to send.
cancellation
CancellationTokenThe CancellationToken to use for cancellation.
Returns
- ValueTask<bool>
A ValueTask<TResult> that represents the asynchronous send operation, which returns true if the message was sent successfully; otherwise, false.