Class UnityWebSocket
Unity implementation of IWebSocket using ClientWebSocket.
Inheritance
UnityWebSocket
Assembly: Glitch9.IO.dll
Syntax
public class UnityWebSocket : IWebSocket, IDisposable
Constructors
|
Edit this page
View Source
UnityWebSocket(ClientWebSocket)
Declaration
public UnityWebSocket(ClientWebSocket socket)
Parameters
Properties
|
Edit this page
View Source
OnStateChanged
Event handler for when the WebSocket connection state changes.
Declaration
public Action<WebSocketState> OnStateChanged { get; set; }
Property Value
|
Edit this page
View Source
Socket
Declaration
public ClientWebSocket Socket { get; }
Property Value
|
Edit this page
View Source
State
The current state of the WebSocket connection.
Declaration
public WebSocketState State { get; }
Property Value
|
Edit this page
View Source
SubProtocol
The WebSocket connection object.
Declaration
public string SubProtocol { get; }
Property Value
Methods
|
Edit this page
View Source
CloseAsync(WebSocketCloseStatus, string, CancellationToken)
Close the WebSocket connection.
Declaration
public UniTask CloseAsync(WebSocketCloseStatus closeCode, string reason, CancellationToken cancellationToken)
Parameters
Returns
|
Edit this page
View Source
Connect to the WebSocket server with a Uri endpoint URL.
Declaration
public UniTask ConnectAsync(Uri uri, CancellationToken cancellationToken, params HttpHeader[] headers)
Parameters
Returns
|
Edit this page
View Source
Dispose()
Declaration
|
Edit this page
View Source
ReceiveAsync(ArraySegment<byte>, CancellationToken)
Receive a response from the WebSocket server.
Declaration
public UniTask<WebSocketReceiveResult> ReceiveAsync(ArraySegment<byte> buffer, CancellationToken cancellationToken)
Parameters
Returns
|
Edit this page
View Source
SendAsync(ArraySegment<byte>, WebSocketMessageType, bool, CancellationToken)
Send a buffer to the WebSocket server.
The buffer is binary data.
This is WebSocket equivalent of multi-part/form-data.
Declaration
public UniTask SendAsync(ArraySegment<byte> buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancellationToken)
Parameters
Returns
|
Edit this page
View Source
SendAsync(string, CancellationToken)
Send a message to the WebSocket server.
The message is most likely a JSON string.
This is WebSocket equivalent of application/json.
Declaration
public UniTask SendAsync(string message, CancellationToken token)
Parameters
Returns
Implements
Extension Methods