docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface IWebSocketClient

    An interface for using a Messaging client and listen to events.

    Inherited Members
    IDisposable.Dispose()
    Namespace: Unity.Cloud.Common
    Assembly: Unity.Cloud.Common.dll
    Syntax
    public interface IWebSocketClient : IDisposable

    Properties

    State

    Reference to the current state of the connection

    Declaration
    ConnectionState State { get; }
    Property Value
    Type Description
    ConnectionState

    Methods

    ConnectAsync(Uri, HttpHeaders)

    Attempts opening a connection to a server

    Declaration
    Task ConnectAsync(Uri uri, HttpHeaders headers = null)
    Parameters
    Type Name Description
    Uri uri

    The uri to connect to.

    HttpHeaders headers

    The HTTP headers for the connection request.

    Returns
    Type Description
    Task

    The connection task.

    DisconnectAsync()

    Closes a connection to a server

    Declaration
    Task DisconnectAsync()
    Returns
    Type Description
    Task

    The disconnection task.

    SendAsync(ArraySegment<byte>)

    Method to send binary data to a server

    Declaration
    Task SendAsync(ArraySegment<byte> message)
    Parameters
    Type Name Description
    ArraySegment<byte> message

    The message to send.

    Returns
    Type Description
    Task

    The send message task.

    SendAsync(string)

    Sends a message to a server.

    Declaration
    Task SendAsync(string message)
    Parameters
    Type Name Description
    string message

    The message to send.

    Returns
    Type Description
    Task

    The send message task.

    Events

    ConnectionErrorOccured

    Event invoked when a connection error occurs

    Declaration
    event Action<Exception> ConnectionErrorOccured
    Event Type
    Type Description
    Action<Exception>

    ConnectionStateChanged

    Event invoked when the state changes

    Declaration
    event Action<ConnectionState> ConnectionStateChanged
    Event Type
    Type Description
    Action<ConnectionState>

    DataReceived

    Event invoked when binary data is received from the server

    Declaration
    event Action<ArraySegment<byte>> DataReceived
    Event Type
    Type Description
    Action<ArraySegment<byte>>

    MessageReceived

    Event invoked when a message is received from the server

    Declaration
    event Action<string> MessageReceived
    Event Type
    Type Description
    Action<string>
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)