Class HttpClientRendezvousHttp

Namespace
Unity.Multiplayer.Core

IRendezvousHttp over HttpClient, which Unity's Mono and IL2CPP players support on desktop, mobile and Linux servers (not WebGL).

public sealed class HttpClientRendezvousHttp : IRendezvousHttp, IDisposable
Inheritance
HttpClientRendezvousHttp
Implements
Inherited Members

Constructors

HttpClientRendezvousHttp(HttpClient, bool)

Uses client, whose BaseAddress must be the service's base URL. Disposes it only when ownsClient is true.

public HttpClientRendezvousHttp(HttpClient client, bool ownsClient)

Parameters

client HttpClient
ownsClient bool

Exceptions

ArgumentNullException

client is null.

HttpClientRendezvousHttp(Uri)

Talks to the service at baseUrl with a client of its own.

public HttpClientRendezvousHttp(Uri baseUrl)

Parameters

baseUrl Uri

Exceptions

ArgumentNullException

baseUrl is null.

Fields

DefaultTimeout

How long one request may take by default.

public static readonly TimeSpan DefaultTimeout

Field Value

TimeSpan

Methods

Dispose()

Disposes the HttpClient if this object created it.

public void Dispose()

SendAsync(string, string, string, IReadOnlyDictionary<string, string>, CancellationToken)

Sends method path (relative to the service's base URL) with an optional JSON body and extra headers, and returns the status and body. Throws only when no response came back (the service is unreachable, or the request timed out).

public Task<RendezvousHttpResponse> SendAsync(string method, string path, string jsonBody, IReadOnlyDictionary<string, string> headers, CancellationToken cancellationToken)

Parameters

method string
path string
jsonBody string
headers IReadOnlyDictionary<string, string>
cancellationToken CancellationToken

Returns

Task<RendezvousHttpResponse>

WithTrailingSlash(Uri)

baseUrl ending in a slash, so relative routes resolve under its path (https://example.com/rendezvous + v1/register → https://example.com/rendezvous/v1/register).

public static Uri WithTrailingSlash(Uri baseUrl)

Parameters

baseUrl Uri

Returns

Uri

Exceptions

ArgumentNullException

baseUrl is null.