Search Results for

    Show / Hide Table of Contents

    Class UnityWebSocket

    Unity implementation of IWebSocket using ClientWebSocket.

    Inheritance
    object
    UnityWebSocket
    Implements
    IWebSocket
    IDisposable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Glitch9.IO.Networking.WebSocket
    Assembly: Glitch9.IO.dll
    Syntax
    public class UnityWebSocket : IWebSocket, IDisposable

    Constructors

    | Edit this page View Source

    UnityWebSocket(ClientWebSocket)

    Declaration
    public UnityWebSocket(ClientWebSocket socket)
    Parameters
    Type Name Description
    ClientWebSocket socket

    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
    Type Description
    Action<WebSocketState>
    | Edit this page View Source

    Socket

    Declaration
    public ClientWebSocket Socket { get; }
    Property Value
    Type Description
    ClientWebSocket
    | Edit this page View Source

    State

    The current state of the WebSocket connection.

    Declaration
    public WebSocketState State { get; }
    Property Value
    Type Description
    WebSocketState
    | Edit this page View Source

    SubProtocol

    The WebSocket connection object.

    Declaration
    public string SubProtocol { get; }
    Property Value
    Type Description
    string

    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
    Type Name Description
    WebSocketCloseStatus closeCode
    string reason
    CancellationToken cancellationToken
    Returns
    Type Description
    UniTask
    | Edit this page View Source

    ConnectAsync(Uri, CancellationToken, params HttpHeader[])

    Connect to the WebSocket server with a Uri endpoint URL.

    Declaration
    public UniTask ConnectAsync(Uri uri, CancellationToken cancellationToken, params HttpHeader[] headers)
    Parameters
    Type Name Description
    Uri uri
    CancellationToken cancellationToken
    HttpHeader[] headers
    Returns
    Type Description
    UniTask
    | Edit this page View Source

    Dispose()

    Declaration
    public void Dispose()
    | 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
    Type Name Description
    ArraySegment<byte> buffer
    CancellationToken cancellationToken
    Returns
    Type Description
    UniTask<WebSocketReceiveResult>
    | 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
    Type Name Description
    ArraySegment<byte> buffer
    WebSocketMessageType messageType
    bool endOfMessage
    CancellationToken cancellationToken
    Returns
    Type Description
    UniTask
    | 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
    Type Name Description
    string message
    CancellationToken token
    Returns
    Type Description
    UniTask

    Implements

    IWebSocket
    IDisposable

    Extension Methods

    ArrayExtensions.ToArrayOrEmpty<T>(T)
    ArrayExtensions.ToArrayOrNull<T>(T)
    EventExtensions.ToDelta<T>(T, string, int, string, bool)
    EventExtensions.ToDone<T>(T, string, int, string)
    EventExtensions.ToEvent<T>(T)
    EventExtensions.UpcastDelta<T1, T2>(T1, string, int, string, bool)
    FallbackExtensions.IsOr<TParent, TChild>(TParent, TChild)
    ResponseCastingExtensions.GetResult<T>(T)
    SystemExtensions.TryDispose(IDisposable)
    SystemExtensions.GetName(object)
    • Edit this page
    • View Source
    In this article
    Back to top AI DevKit Documentation