Class CommonNetworkParametersExtensions
Extensions for NetworkConfigParameter.
Inherited Members
Namespace: Unity.Networking.Transport
Assembly: Unity.Networking.Transport.dll
Syntax
public static class CommonNetworkParametersExtensions
Methods
GetNetworkConfigParameters(ref NetworkSettings)
Gets the NetworkConfigParameter in the settings.
Declaration
public static NetworkConfigParameter GetNetworkConfigParameters(this ref NetworkSettings settings)
Parameters
Type | Name | Description |
---|---|---|
NetworkSettings | settings | Settings to get parameters from. |
Returns
Type | Description |
---|---|
NetworkConfigParameter | Structure containing the network parameters. |
WithNetworkConfigParameters(ref NetworkSettings, int, int, int, int, int, int, int, int, int, bool)
Declaration
public static ref NetworkSettings WithNetworkConfigParameters(this ref NetworkSettings settings, int connectTimeoutMS, int maxConnectAttempts, int disconnectTimeoutMS, int heartbeatTimeoutMS, int reconnectionTimeoutMS, int maxFrameTimeMS, int fixedFrameTimeMS, int receiveQueueCapacity, int sendQueueCapacity, bool performPathMtuDiscovery)
Parameters
Type | Name | Description |
---|---|---|
NetworkSettings | settings | |
int | connectTimeoutMS | |
int | maxConnectAttempts | |
int | disconnectTimeoutMS | |
int | heartbeatTimeoutMS | |
int | reconnectionTimeoutMS | |
int | maxFrameTimeMS | |
int | fixedFrameTimeMS | |
int | receiveQueueCapacity | |
int | sendQueueCapacity | |
bool | performPathMtuDiscovery |
Returns
Type | Description |
---|---|
NetworkSettings |
WithNetworkConfigParameters(ref NetworkSettings, int, int, int, int, int, int, int, int, int, int, bool)
Sets the NetworkConfigParameter in the settings.
Declaration
public static ref NetworkSettings WithNetworkConfigParameters(this ref NetworkSettings settings, int connectTimeoutMS = 1000, int maxConnectAttempts = 60, int disconnectTimeoutMS = 30000, int heartbeatTimeoutMS = 500, int reconnectionTimeoutMS = 2000, int maxFrameTimeMS = 0, int fixedFrameTimeMS = 0, int receiveQueueCapacity = 512, int sendQueueCapacity = 512, int maxMessageSize = 1400, bool performPathMtuDiscovery = false)
Parameters
Type | Name | Description |
---|---|---|
NetworkSettings | settings | Settings to modify. |
int | connectTimeoutMS | Time between connection attempts. |
int | maxConnectAttempts | Maximum number of connection attempts to try. If no answer is received from the server after this number of attempts, a Disconnect event is generated for the connection. |
int | disconnectTimeoutMS | Inactivity timeout for a connection. If nothing is received on a connection for this
amount of time, it is disconnected (a Disconnect event
will be generated). To prevent this from happenning when the game session is simply
quiet, set |
int | heartbeatTimeoutMS | Time after which if nothing from a peer is received, a heartbeat message will be sent
to keep the connection alive. Prevents the |
int | reconnectionTimeoutMS | Time after which to attempt to re-establish a connection if nothing is received from the
peer. This is used to re-establish connections for example when a peer's IP address
changes (e.g. mobile roaming scenarios). To be effective, should be less than
|
int | maxFrameTimeMS | Maximum amount of time a single frame can advance timeout values. In this scenario, a frame is defined as the time between two ScheduleUpdate(JobHandle) calls. Useful when debugging to avoid connection timeouts. |
int | fixedFrameTimeMS | Fixes a fixed amount of time to be used each frame for the purpose of timeout calculations. For example, setting this value to 1000 will have the driver consider that 1 second passed between each call to ScheduleUpdate(JobHandle), even if that's not actually the case. Only useful for testing scenarios, where deterministic behavior is more important than correctness. |
int | receiveQueueCapacity | Capacity of the receive queue. This should be the maximum number of packets expected to be received in a single update (each frame). The best value for this will depend heavily on the game type, but generally should be a multiple of the maximum number of players. The only impact of increasing this value is increased memory usage, with an expected ~1400 bytes of memory being used per unit of capacity. The queue is shared across all connections, so servers should set this higher than clients. |
int | sendQueueCapacity | Capacity of the send queue. This should be the maximum number of packets expected to be send in a single update (each frame). The best value will depend heavily on the game type, but generally should be a multiple of the maximum number of players. The only impact of increasing this value is increased memory usage, with an expected ~1400 bytes of memory being used per unity of capacity. The queue is shared across all connections, so servers should set this higher than clients. |
int | maxMessageSize | Maximum size of a packet that can be sent by the transport. Note that this size includes any headers that could be added by the transport (e.g. headers for DTLS or pipelines), which means the actual maximum message size that can be sent by a user is slightly less than this value. |
bool | performPathMtuDiscovery | Whether or not to perform Path MTU discovery. If this is false, the connection's path MTU will always be maxMessageSize. If true, then during the connection handshake, a path MTU discovery pass will be performed. If the discovered MTU is smaller than maxMessageSize, the max message size for that connection will be reduced accordingly, but if larger, it will never exceed maxMessageSize. This process is only done once during connection; we do not attempt to discover changes in the Path MTU during gameplay, as many gameplay systems are not built to be able to adapt to such changes. |
Returns
Type | Description |
---|---|
NetworkSettings | Settings structure with modified values. |