docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class RelayAllocationsApi

    Represents a collection of functions to interact with the API endpoints

    Inheritance
    object
    RelayAllocationsApi
    Implements
    IRelayAllocationsApi
    IApiAccessor
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Unity.Services.Apis.Relay
    Assembly: solution.dll
    Syntax
    public class RelayAllocationsApi : IRelayAllocationsApi, IApiAccessor

    Constructors

    RelayAllocationsApi(IApiClient)

    Initializes a new instance of the RelayAllocationsApi class using a Configuration object and client instance.

    Declaration
    public RelayAllocationsApi(IApiClient apiClient)
    Parameters
    Type Name Description
    IApiClient apiClient

    The client interface for synchronous API access.

    RelayAllocationsApi(IApiClient, IApiConfiguration)

    Initializes a new instance of the RelayAllocationsApi class using a Configuration object and client instance.

    Declaration
    public RelayAllocationsApi(IApiClient apiClient, IApiConfiguration apiConfiguration)
    Parameters
    Type Name Description
    IApiClient apiClient

    The client interface for synchronous API access.

    IApiConfiguration apiConfiguration

    The configuration object.

    Properties

    Client

    The client for accessing this underlying API asynchronously.

    Declaration
    public IApiClient Client { get; }
    Property Value
    Type Description
    IApiClient

    Configuration

    Gets the configuration object

    Declaration
    public IApiConfiguration Configuration { get; }
    Property Value
    Type Description
    IApiConfiguration

    An instance of the Configuration

    Methods

    CreateAllocation(AllocationRequest, CancellationToken)

    Create an allocation. Create an allocation on an available Relay server. If you provide the region, the Allocations service looks for a Relay server in the specified region. The Allocations service uses the default region if you do not provide the region (Central United States - Iowa). The Allocations service determines the best available Relay server based on the resolved region's available capacity and server health. See the QoS documentation to learn more. If the Allocations service fails to find a Relay server during the lifetime of the request, the client should retry. This endpoint returns a unique ID for the allocation (which you can use to generate a join code), details of the selected Relay server, encrypted connection data for the caller, and a key required for building the BIND message HMAC. > Note: The Relay service removes the player if the client fails to send a BIND message or a PING message before the allocation expires (10 seconds by default). See the Client timeouts documentation.

    Declaration
    public ApiOperation<AllocateResponseBody> CreateAllocation(AllocationRequest allocationRequest, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    AllocationRequest allocationRequest
    CancellationToken cancellationToken

    Cancellation Token to cancel the request.

    Returns
    Type Description
    ApiOperation<AllocateResponseBody>

    The operation

    CreateJoincode(JoinCodeRequest, CancellationToken)

    Create a join code. Create a join code for the given allocation ID. You can think of a join code as a short-hand lookup for a host player's connection data. The connecting player can retrieve the host player's connection data via a mapping between the allocation ID and the join code. Join codes allow players to coordinate themselves into a logical session. The player who creates the initial allocation acts as a host. This host player's client calls this endpoint to get a join code. The host player can then share with other players. See the Join code documentation to learn more. The connecting players can use the join code with /join endpoint to connect to a Relay server to communicate with the host player. The host is not required to make a BIND call to the Relay server before generating a join code. Only the client that created the allocation via the /allocate endpoint can generate a join code.

    Declaration
    public ApiOperation<JoinCodeResponseBody> CreateJoincode(JoinCodeRequest joinCodeRequest, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    JoinCodeRequest joinCodeRequest
    CancellationToken cancellationToken

    Cancellation Token to cancel the request.

    Returns
    Type Description
    ApiOperation<JoinCodeResponseBody>

    The operation

    GetBasePath()

    Gets the base path of the API client.

    Declaration
    public string GetBasePath()
    Returns
    Type Description
    string

    The base path

    JoinRelay(JoinRequest, CancellationToken)

    Join a Relay server. Join a Relay server with a join code. This endpoint allows connecting players to retrieve the connection details of a host player using a join code they received from the host player. The connecting player can then use the connection details to connect with the host player through the host player's Relay server. A join code is a short-hand code that Relay uses to lookup the connection data of the player who created it (the host player). Connecting players can perform this lookup to determine the information necessary to connect to the host player's Relay server. > Note: The Relay service removes the player if the client fails to send a BIND message or a PING message before the allocation expires (10 seconds by default). See the Client timeouts documentation.

    Declaration
    public ApiOperation<JoinResponseBody> JoinRelay(JoinRequest joinRequest, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    JoinRequest joinRequest
    CancellationToken cancellationToken

    Cancellation Token to cancel the request.

    Returns
    Type Description
    ApiOperation<JoinResponseBody>

    The operation

    ListRegions(CancellationToken)

    List available Relay regions. List all available regions with Relay servers. The presence of a region in this list does not guarantee that there will be a Relay server ready to handle allocations in every region listed.

    Declaration
    public ApiOperation<RegionsResponseBody> ListRegions(CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    Cancellation Token to cancel the request.

    Returns
    Type Description
    ApiOperation<RegionsResponseBody>

    The operation

    Implements

    IRelayAllocationsApi
    IApiAccessor
    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)