Uređivanje

Dijeli putem


WebSocket.SendAsync Method

Definition

Overloads

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

Sends data over the WebSocket connection asynchronously.

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

Sends data over the WebSocket connection asynchronously.

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

Sends data over the WebSocket connection asynchronously.

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

Source:
WebSocket.cs
Source:
WebSocket.cs
Source:
WebSocket.cs

Sends data over the WebSocket connection asynchronously.

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

Parameters

buffer
ArraySegment<Byte>

The buffer to be sent over the connection.

messageType
WebSocketMessageType

Indicates whether the application is sending a binary or text message.

endOfMessage
Boolean

Indicates whether the data in "buffer" is the last part of a message.

cancellationToken
CancellationToken

The token that propagates the notification that operations 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 data has been sent on the WebSocket.

Exactly one send and one receive is supported on each WebSocket 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:
WebSocket.cs
Source:
WebSocket.cs
Source:
WebSocket.cs

Sends data over the WebSocket connection asynchronously.

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

Parameters

buffer
ReadOnlyMemory<Byte>

The buffer to be sent over the connection.

messageType
WebSocketMessageType

One of the enumeration values that indicates whether the application is sending a binary or text message.

endOfMessage
Boolean

true to indicate the data in "buffer" is the last part of a message; otherwise, false.

cancellationToken
CancellationToken

The cancellation token to use to cancel the send operation.

Returns

The task object representing the asynchronous operation.

Exceptions

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

Applies to

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

Source:
WebSocket.cs
Source:
WebSocket.cs
Source:
WebSocket.cs

Sends data over the WebSocket connection asynchronously.

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

Parameters

buffer
ReadOnlyMemory<Byte>

The buffer to be sent over the connection.

messageType
WebSocketMessageType

One of the enumeration values that indicates whether the application is sending a binary or text message.

messageFlags
WebSocketMessageFlags

Flags for controlling how the WebSocket should send a message.

cancellationToken
CancellationToken

The cancellation token to use to cancel the send operation.

Returns

The task object representing the asynchronous operation.

Exceptions

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

Applies to