Редагувати

Поділитися через


ClientWebSocket.SendAsync Method

Definition

Overloads

SendAsync(ArraySegment<Byte>, WebSocketMessageType, Boolean, CancellationToken)

Sends data on ClientWebSocket as an asynchronous operation.

SendAsync(ReadOnlyMemory<Byte>, WebSocketMessageType, Boolean, CancellationToken)

Sends data on ClientWebSocket from a read-only byte memory range as an asynchronous operation.

SendAsync(ReadOnlyMemory<Byte>, WebSocketMessageType, WebSocketMessageFlags, CancellationToken)

Sends data on ClientWebSocket from a read-only byte memory range as an asynchronous operation.

SendAsync(ArraySegment<Byte>, WebSocketMessageType, Boolean, CancellationToken)

Source:
ClientWebSocket.cs
Source:
ClientWebSocket.cs
Source:
ClientWebSocket.cs

Sends data on ClientWebSocket as an asynchronous operation.

public:
 override System::Threading::Tasks::Task ^ SendAsync(ArraySegment<System::Byte> buffer, System::Net::WebSockets::WebSocketMessageType messageType, bool endOfMessage, System::Threading::CancellationToken cancellationToken);
public override System.Threading.Tasks.Task SendAsync (ArraySegment<byte> buffer, System.Net.WebSockets.WebSocketMessageType messageType, bool endOfMessage, System.Threading.CancellationToken cancellationToken);
override this.SendAsync : ArraySegment<byte> * System.Net.WebSockets.WebSocketMessageType * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Overrides Function SendAsync (buffer As ArraySegment(Of Byte), messageType As WebSocketMessageType, endOfMessage As Boolean, cancellationToken As CancellationToken) As Task

Parameters

buffer
ArraySegment<Byte>

The buffer containing the message to be sent.

messageType
WebSocketMessageType

One of the enumeration values that specifies whether the buffer is clear text or in a binary format.

endOfMessage
Boolean

true to indicate this is the final asynchronous send; otherwise, false.

cancellationToken
CancellationToken

A cancellation token used to propagate notification that this operation should be canceled.

Returns

The task object representing the asynchronous operation.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

This operation will not block. The returned Task object will complete after the send request on the ClientWebSocket instance has completed.

Exactly one send and one receive is supported on each ClientWebSocket object in parallel. Issuing multiple sends at the same time is not supported and will result in an undefined behavior. You should serialize send operations via whatever mechanism works best for you, for example, by using a lock or a semaphore.

Applies to

SendAsync(ReadOnlyMemory<Byte>, WebSocketMessageType, Boolean, CancellationToken)

Source:
ClientWebSocket.cs
Source:
ClientWebSocket.cs
Source:
ClientWebSocket.cs

Sends data on ClientWebSocket from a read-only byte memory range as an asynchronous operation.

public:
 override System::Threading::Tasks::ValueTask SendAsync(ReadOnlyMemory<System::Byte> buffer, System::Net::WebSockets::WebSocketMessageType messageType, bool endOfMessage, System::Threading::CancellationToken cancellationToken);
public override System.Threading.Tasks.ValueTask SendAsync (ReadOnlyMemory<byte> buffer, System.Net.WebSockets.WebSocketMessageType messageType, bool endOfMessage, System.Threading.CancellationToken cancellationToken);
override this.SendAsync : ReadOnlyMemory<byte> * System.Net.WebSockets.WebSocketMessageType * bool * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask
Public Overrides Function SendAsync (buffer As ReadOnlyMemory(Of Byte), messageType As WebSocketMessageType, endOfMessage As Boolean, cancellationToken As CancellationToken) As ValueTask

Parameters

buffer
ReadOnlyMemory<Byte>

The region of memory containing the message to be sent.

messageType
WebSocketMessageType

One of the enumeration values that specifies whether the buffer is clear text or in a binary format.

endOfMessage
Boolean

true to indicate this is the final asynchronous send; otherwise, false.

cancellationToken
CancellationToken

A cancellation token used to propagate notification that this operation should be canceled.

Returns

The task object representing the asynchronous operation.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

This operation will not block. The returned Task object will complete after the send request on the ClientWebSocket instance has completed.

Exactly one send and one receive is supported on each ClientWebSocket object in parallel. Issuing multiple sends at the same time is not supported and will result in an undefined behavior. You should serialize send operations via whatever mechanism works best for you, for example, by using a lock or a semaphore.

Applies to

SendAsync(ReadOnlyMemory<Byte>, WebSocketMessageType, WebSocketMessageFlags, CancellationToken)

Source:
ClientWebSocket.cs
Source:
ClientWebSocket.cs

Sends data on ClientWebSocket from a read-only byte memory range as an asynchronous operation.

public:
 override System::Threading::Tasks::ValueTask SendAsync(ReadOnlyMemory<System::Byte> buffer, System::Net::WebSockets::WebSocketMessageType messageType, System::Net::WebSockets::WebSocketMessageFlags messageFlags, System::Threading::CancellationToken cancellationToken);
public override System.Threading.Tasks.ValueTask SendAsync (ReadOnlyMemory<byte> buffer, System.Net.WebSockets.WebSocketMessageType messageType, System.Net.WebSockets.WebSocketMessageFlags messageFlags, System.Threading.CancellationToken cancellationToken);
override this.SendAsync : ReadOnlyMemory<byte> * System.Net.WebSockets.WebSocketMessageType * System.Net.WebSockets.WebSocketMessageFlags * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask
Public Overrides Function SendAsync (buffer As ReadOnlyMemory(Of Byte), messageType As WebSocketMessageType, messageFlags As WebSocketMessageFlags, cancellationToken As CancellationToken) As ValueTask

Parameters

buffer
ReadOnlyMemory<Byte>

The region of memory containing the message to be sent.

messageType
WebSocketMessageType

One of the enumeration values that specifies whether the buffer is clear text or in a binary format.

messageFlags
WebSocketMessageFlags

A bitwise combination of the enumeration values that specifies how the message will be sent.

cancellationToken
CancellationToken

A cancellation token used to propagate notification that this operation should be canceled.

Returns

The task object representing the asynchronous operation.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

This operation does not block. The returned Task object completes after the send request on the ClientWebSocket instance has completed.

Exactly one send and one receive is supported on each ClientWebSocket object in parallel. Issuing multiple sends at the same time is not supported and will result in an undefined behavior. You should serialize send operations via whatever mechanism works best for you, for example, by using a lock or a semaphore.

Applies to