Struct RelayServerData
Connection information about the relay server.
Inherited Members
Namespace: Unity.Networking.Transport.Relay
Assembly: Unity.Networking.Transport.dll
Syntax
public struct RelayServerData
Constructors
RelayServerData(string, ushort, byte[], byte[], byte[], byte[], bool)
Create a new Relay server data structure.
Declaration
public RelayServerData(string host, ushort port, byte[] allocationId, byte[] connectionData, byte[] hostConnectionData, byte[] key, bool isSecure)
Parameters
Type | Name | Description |
---|---|---|
string | host | IP address or hostname of the Relay server. |
ushort | port | Port of the Relay server. |
byte[] | allocationId | ID of the Relay allocation. |
byte[] | connectionData | Connection data of the allocation. |
byte[] | hostConnectionData | Connection data of the host (same as previous for hosts). |
byte[] | key | HMAC signature of the allocation. |
bool | isSecure | Whether the Relay connection is to be secured or not. |
Remarks
If a hostname is provided as the "host" parameter, this constructor will perform a DNS
resolution to map it to an IP address. If the hostname is not in the OS cache, this
operation can possibly block for a long time (between 20 and 120 milliseconds). If this
is a concern, perform the DNS resolution asynchronously and pass in the resulting IP
address directly (for example with System.Net.Dns.GetHostEntryAsync"
).
RelayServerData(string, ushort, byte[], byte[], byte[], byte[], bool, bool)
Create a new Relay server data structure.
Declaration
public RelayServerData(string host, ushort port, byte[] allocationId, byte[] connectionData, byte[] hostConnectionData, byte[] key, bool isSecure, bool isWebSocket)
Parameters
Type | Name | Description |
---|---|---|
string | host | IP address or hostname of the Relay server. |
ushort | port | Port of the Relay server. |
byte[] | allocationId | ID of the Relay allocation. |
byte[] | connectionData | Connection data of the allocation. |
byte[] | hostConnectionData | Connection data of the host (same as previous for hosts). |
byte[] | key | HMAC signature of the allocation. |
bool | isSecure | Whether the Relay connection is to be secured or not. |
bool | isWebSocket | Whether the Relay connection is using WebSockets or not. |
Remarks
If a hostname is provided as the "host" parameter, this constructor will perform a DNS
resolution to map it to an IP address. If the hostname is not in the OS cache, this
operation can possibly block for a long time (between 20 and 120 milliseconds). If this
is a concern, perform the DNS resolution asynchronously and pass in the resulting IP
address directly (for example with System.Net.Dns.GetHostEntryAsync"
).
RelayServerData(ref NetworkEndpoint, ushort, ref RelayAllocationId, ref RelayConnectionData, ref RelayConnectionData, ref RelayHMACKey, bool)
Declaration
public RelayServerData(ref NetworkEndpoint endpoint, ushort nonce, ref RelayAllocationId allocationId, ref RelayConnectionData connectionData, ref RelayConnectionData hostConnectionData, ref RelayHMACKey key, bool isSecure)
Parameters
Type | Name | Description |
---|---|---|
Network |
endpoint | |
ushort | nonce | |
Relay |
allocationId | |
Relay |
connectionData | |
Relay |
hostConnectionData | |
Relay |
key | |
bool | isSecure |
RelayServerData(ref NetworkEndpoint, ushort, ref RelayAllocationId, ref RelayConnectionData, ref RelayConnectionData, ref RelayHMACKey, bool, bool)
Create a new Relay server data structure (low-level constructor).
Declaration
public RelayServerData(ref NetworkEndpoint endpoint, ushort nonce, ref RelayAllocationId allocationId, ref RelayConnectionData connectionData, ref RelayConnectionData hostConnectionData, ref RelayHMACKey key, bool isSecure, bool isWebSocket)
Parameters
Type | Name | Description |
---|---|---|
Network |
endpoint | Endpoint of the Relay server. |
ushort | nonce | Nonce used in connection handshake (preferably random). |
Relay |
allocationId | ID of the Relay allocation. |
Relay |
connectionData | Connection data of the allocation. |
Relay |
hostConnectionData | Connection data of the host (use default for hosts). |
Relay |
key | HMAC signature of the allocation. |
bool | isSecure | Whether the Relay connection is to be secured or not. |
bool | isWebSocket | Whether the Relay connection is using WebSockets or not. |
Fields
AllocationId
Allocation ID for the server connection.
Declaration
public RelayAllocationId AllocationId
Field Value
Type | Description |
---|---|
Relay |
Allocation ID. |
ConnectionData
Connection data of the allocation.
Declaration
public RelayConnectionData ConnectionData
Field Value
Type | Description |
---|---|
Relay |
Connection data structure. |
Endpoint
Endpoint the relay server can be reached on.
Declaration
public NetworkEndpoint Endpoint
Field Value
Type | Description |
---|---|
Network |
Server endpoint (IP address and port). |
HMACKey
HMAC key used to authentify the connection.
Declaration
public RelayHMACKey HMACKey
Field Value
Type | Description |
---|---|
Relay |
HMAC key. |
HostConnectionData
Connection data of the host.
Declaration
public RelayConnectionData HostConnectionData
Field Value
Type | Description |
---|---|
Relay |
Connection data structure. |
IsSecure
Whether the connection is using a secure protocol or not.
Declaration
public readonly byte IsSecure
Field Value
Type | Description |
---|---|
byte | True if using DTLS or WSS, false if using UDP. |
IsWebSocket
Whether the connection is using the WebSocket protocol.
Declaration
public readonly byte IsWebSocket
Field Value
Type | Description |
---|---|
byte | True if using WSS, false if using UDP or DTLS. |
Nonce
Nonce that will be used in the connection handshake.
Declaration
public ushort Nonce
Field Value
Type | Description |
---|---|
ushort | HMAC key nonce. |
Methods
IncrementNonce()
Increment the nonce and recompute the HMAC.
Declaration
public void IncrementNonce()