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
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
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
Port
The public port players connect to.
public ushort Port { get; }
Property Value
Source
Where the address and port came from, for the log ("config", "RunPod", "local port").
public string Source { get; }
Property Value
Transport
The transport players must connect with.
public TransportKind Transport { get; }
Property Value
Warnings
Problems worth logging (for example a UDP server on RunPod, which maps TCP only). Never null.
public IReadOnlyList<string> Warnings { get; }
Property Value
Methods
Explicit(string, ushort, TransportKind)
An explicit advertisement.
public static ServerAdvertisement Explicit(string address, ushort port, TransportKind transport)
Parameters
addressstringportushorttransportTransportKind
Returns
Exceptions
- ArgumentException
The port is 0.
For(NetConfig, Func<string, string>)
Works out what config's server should advertise. In order:
- The port: PublicPort when set; else, on RunPod with a WebSocket transport,
RUNPOD_TCP_PORT_{Port}; else the port the server listens on. - 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
configNetConfigThe server's config.
environmentFunc<string, string>Reads an environment variable (null when unset); null reads the process environment.
Returns
Exceptions
- ArgumentNullException
configis null.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.