Class RendezvousClient

Namespace
Unity.Multiplayer.Core

Speaks the self-hosted rendezvous service's HTTP API (RendezvousProtocol): register a dedicated server, keep its registration alive, resolve a code a player typed, and unregister. Thread-safe; every call is one request.

public sealed class RendezvousClient : IDisposable
Inheritance
RendezvousClient
Implements
Inherited Members

Constructors

RendezvousClient(string)

Talks to the service at baseUrl (http or https) over HttpClientRendezvousHttp.

public RendezvousClient(string baseUrl)

Parameters

baseUrl string

Exceptions

ArgumentException

baseUrl is not an absolute http(s) URL.

RendezvousClient(IRendezvousHttp, bool)

Talks to the service through http; disposes it only when ownsHttp is true.

public RendezvousClient(IRendezvousHttp http, bool ownsHttp = false)

Parameters

http IRendezvousHttp
ownsHttp bool

Exceptions

ArgumentNullException

http is null.

Methods

Dispose()

Disposes the HTTP transport if this client owns it.

public void Dispose()

HeartbeatAsync(JoinCode, string, CancellationToken)

Renews a registration for another TTL. False when the service no longer knows it (404): register again.

public Task<bool> HeartbeatAsync(JoinCode code, string token, CancellationToken cancellationToken = default)

Parameters

code JoinCode
token string
cancellationToken CancellationToken

Returns

Task<bool>

Exceptions

RendezvousException

Any other refusal, or the service could not be reached.

IsValidBaseUrl(string)

True when baseUrl is an absolute http(s) URL.

public static bool IsValidBaseUrl(string baseUrl)

Parameters

baseUrl string

Returns

bool

ParseBaseUrl(string)

Parses a rendezvous base URL: absolute, http or https.

public static Uri ParseBaseUrl(string baseUrl)

Parameters

baseUrl string

Returns

Uri

Exceptions

ArgumentException

It is not.

RegisterAsync(string, string, ushort, TransportKind, CancellationToken)

Registers a server and returns its code and private token. A null or empty address asks the service to use the address the request came from.

public Task<RendezvousRegistration> RegisterAsync(string secret, string address, ushort port, TransportKind transport, CancellationToken cancellationToken = default)

Parameters

secret string
address string
port ushort
transport TransportKind
cancellationToken CancellationToken

Returns

Task<RendezvousRegistration>

Exceptions

RendezvousException

The service refused (wrong secret, bad endpoint, full) or could not be reached.

ResolveAsync(JoinCode, CancellationToken)

The server code leads to, or null when the service does not know the code (404, or 400 for a malformed one).

public Task<JoinTarget> ResolveAsync(JoinCode code, CancellationToken cancellationToken = default)

Parameters

code JoinCode
cancellationToken CancellationToken

Returns

Task<JoinTarget>

Exceptions

RendezvousException

Any other refusal (such as 429), or the service could not be reached.

UnregisterAsync(JoinCode, string, CancellationToken)

Deletes a registration. False when the service did not know it (404).

public Task<bool> UnregisterAsync(JoinCode code, string token, CancellationToken cancellationToken = default)

Parameters

code JoinCode
token string
cancellationToken CancellationToken

Returns

Task<bool>

Exceptions

RendezvousException

Any other refusal, or the service could not be reached.