docs.unity3d.com
    Show / Hide Table of Contents

    Class ServiceMessagingClient

    Interface for a messaging client used to connect to a service and send/receive messages

    Inheritance
    Object
    ServiceMessagingClient
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.Cloud.Common
    Syntax
    public class ServiceMessagingClient : IServiceMessagingClient, IDisposable

    Constructors

    ServiceMessagingClient(IWebSocketClient, IAccessTokenProvider, IAppIdProvider)

    Creates an instance of ServiceMessagingClient

    Declaration
    public ServiceMessagingClient(IWebSocketClient webSocketClient, IAccessTokenProvider accessTokenProvider = null, IAppIdProvider appIdProvider = null)
    Parameters
    Type Name Description
    IWebSocketClient webSocketClient

    IWebSocketClient provided.

    IAccessTokenProvider accessTokenProvider

    Provider of access tokens.

    IAppIdProvider appIdProvider

    Provider of the application identifier.

    Properties

    State

    Reference to the current state of the connection

    Declaration
    public ConnectionState State { get; }
    Property Value
    Type Description
    ConnectionState
    Implements
    IServiceMessagingClient.State

    Methods

    AddApiSourceVersion(String, String)

    Adds an ApiSourceVersion to the client.

    Declaration
    public void AddApiSourceVersion(string name, string version)
    Parameters
    Type Name Description
    String name

    The API source name.

    String version

    The API source version.

    Implements
    IServiceMessagingClient.AddApiSourceVersion(String, String)
    Exceptions
    Type Condition
    ArgumentNullException

    Thrown is name or version are null or whitespace.

    AddApiSourceVersion(ApiSourceVersion)

    Adds an ApiSourceVersion to the client.

    Declaration
    public void AddApiSourceVersion(ApiSourceVersion apiSourceVersion)
    Parameters
    Type Name Description
    ApiSourceVersion apiSourceVersion

    The version information for the API using this client.

    Implements
    IServiceMessagingClient.AddApiSourceVersion(ApiSourceVersion)
    Exceptions
    Type Condition
    ArgumentNullException

    Thrown if apiSourceVersion is null or any of its fields are null or whitespace.

    ConnectAsync(Uri, ServiceMessagingClientOptions, CancellationToken)

    Awaitable method to open a connection to a service using the given url using messaging client options

    Declaration
    public async Task ConnectAsync(Uri uri, ServiceMessagingClientOptions options = default(ServiceMessagingClientOptions), CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    Uri uri

    Uri

    ServiceMessagingClientOptions options

    The selected options

    CancellationToken cancellationToken

    Optional cancellation token that will try to cancel the operation.

    Returns
    Type Description
    Task
    Implements
    IServiceMessagingClient.ConnectAsync(Uri, ServiceMessagingClientOptions, CancellationToken)

    DisconnectAsync()

    Awaitable method to close a connection to a server

    Declaration
    public Task DisconnectAsync()
    Returns
    Type Description
    Task
    Implements
    IServiceMessagingClient.DisconnectAsync()

    Dispose()

    Ensure disposal of any IDisposable references.

    Declaration
    public void Dispose()
    Implements
    IDisposable.Dispose()

    Dispose(Boolean)

    Ensure internal disposal of any IDisposable references.

    Declaration
    protected virtual void Dispose(bool disposing)
    Parameters
    Type Name Description
    Boolean disposing

    Dispose pattern boolean value received from public Dispose method.

    SendAsync(IEnumerable<Message>)

    Awaitable method to send a collection of messages to a server

    Declaration
    public Task SendAsync(IEnumerable<Message> messages)
    Parameters
    Type Name Description
    IEnumerable<Message> messages
    Returns
    Type Description
    Task
    Implements
    IServiceMessagingClient.SendAsync(IEnumerable<Message>)

    SendAsync(Message)

    Awaitable method to send a message to a server

    Declaration
    public Task SendAsync(Message message)
    Parameters
    Type Name Description
    Message message
    Returns
    Type Description
    Task
    Implements
    IServiceMessagingClient.SendAsync(Message)

    Events

    ConnectionErrorOccured

    Event invoked when a connection error occurs

    Declaration
    public event Action<Exception> ConnectionErrorOccured
    Event Type
    Type Description
    Action<Exception>
    Implements
    IServiceMessagingClient.ConnectionErrorOccured

    ConnectionStateChanged

    Event invoked when the client's connection state changes

    Declaration
    public event Action<ConnectionState> ConnectionStateChanged
    Event Type
    Type Description
    Action<ConnectionState>
    Implements
    IServiceMessagingClient.ConnectionStateChanged

    MessageReceived

    Event invoked when a message is received from the server

    Declaration
    public event Action<Message> MessageReceived
    Event Type
    Type Description
    Action<Message>
    Implements
    IServiceMessagingClient.MessageReceived

    Extension Methods

    IServiceMessagingClientExtensions.AddApiSourceVersionFromAssembly(IServiceMessagingClient, Assembly)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023