Class ServerAdvertisement

Namespace
Unity.Multiplayer.Core

What a dedicated server tells the rendezvous service about itself: the address and port players connect to, which can differ from what it binds. Behind NAT or a port-mapping host the public port is not the local one; on RunPod a pod's exposed TCP port P is reachable at RUNPOD_PUBLIC_IP:RUNPOD_TCP_PORT_P.

public sealed class ServerAdvertisement
Inheritance
ServerAdvertisement
Inherited Members

Fields

RunPodPublicIpVariable

RunPod's environment variable holding the pod's public IP.

public const string RunPodPublicIpVariable = "RUNPOD_PUBLIC_IP"

Field Value

string

RunPodTcpPortPrefix

Prefix of RunPod's per-port variables: RUNPOD_TCP_PORT_7777=40123 maps internal 7777 to public 40123.

public const string RunPodTcpPortPrefix = "RUNPOD_TCP_PORT_"

Field Value

string

Properties

Address

The public address, or null to let the rendezvous service use the address the registration came from.

public string Address { get; }

Property Value

string

Port

The public port players connect to.

public ushort Port { get; }

Property Value

ushort

Source

Where the address and port came from, for the log ("config", "RunPod", "local port").

public string Source { get; }

Property Value

string

Transport

The transport players must connect with.

public TransportKind Transport { get; }

Property Value

TransportKind

Warnings

Problems worth logging (for example a UDP server on RunPod, which maps TCP only). Never null.

public IReadOnlyList<string> Warnings { get; }

Property Value

IReadOnlyList<string>

Methods

Explicit(string, ushort, TransportKind)

An explicit advertisement.

public static ServerAdvertisement Explicit(string address, ushort port, TransportKind transport)

Parameters

address string
port ushort
transport TransportKind

Returns

ServerAdvertisement

Exceptions

ArgumentException

The port is 0.

For(NetConfig, Func<string, string>)

Works out what config's server should advertise. In order:

  1. The port: PublicPort when set; else, on RunPod with a WebSocket transport, RUNPOD_TCP_PORT_{Port}; else the port the server listens on.
  2. The address: PublicAddress when set; else, when the RunPod port mapping was used, RUNPOD_PUBLIC_IP; else null (the service records the address the registration came from).
public static ServerAdvertisement For(NetConfig config, Func<string, string> environment = null)

Parameters

config NetConfig

The server's config.

environment Func<string, string>

Reads an environment variable (null when unset); null reads the process environment.

Returns

ServerAdvertisement

Exceptions

ArgumentNullException

config is null.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.