Skip to main content

Unity.Netcode.Transports.UTP.UnityTransport

Inheritance#

System.Object

NetworkTransport

UnityTransport

Implements#

INetworkStreamDriverConstructor

Inherited Members#

NetworkTransport.IsSupported

NetworkTransport.OnTransportEvent

NetworkTransport.InvokeOnTransportEvent(NetworkEvent, UInt64, ArraySegment\<Byte>, Single)

Syntax#
public class UnityTransport : NetworkTransport, INetworkStreamDriverConstructor

Fields#

ConnectionData#

Declaration#
public UnityTransport.ConnectionAddressData ConnectionData
Field Value#
TypeDescription
UnityTransport.ConnectionAddressData

DebugSimulator#

Declaration#
public UnityTransport.SimulatorParameters DebugSimulator
Field Value#
TypeDescription
UnityTransport.SimulatorParameters

InitialMaxPacketQueueSize#

Declaration#
public const int InitialMaxPacketQueueSize = 128
Field Value#
TypeDescription
System.Int32

InitialMaxPayloadSize#

Declaration#
public const int InitialMaxPayloadSize = 6144
Field Value#
TypeDescription
System.Int32

InitialMaxSendQueueSize#

Declaration#
public const int InitialMaxSendQueueSize = 98304
Field Value#
TypeDescription
System.Int32

s_DriverConstructor#

Declaration#
public static INetworkStreamDriverConstructor s_DriverConstructor
Field Value#
TypeDescription
INetworkStreamDriverConstructor

Properties#

ConnectTimeoutMS#

Timeout in milliseconds indicating how long we will wait until we send a new connection attempt.

Declaration#
public int ConnectTimeoutMS { get; set; }
Property Value#
TypeDescription
System.Int32

DisconnectTimeoutMS#

Inactivity timeout after which a connection will be disconnected.

Declaration#
public int DisconnectTimeoutMS { get; set; }
Property Value#
TypeDescription
System.Int32
Remarks#

The connection needs to receive data from the connected endpoint within this timeout. Note that with heartbeats enabled, simply not sending any data will not be enough to trigger this timeout (since heartbeats count as connection events).

DriverConstructor#

Declaration#
public INetworkStreamDriverConstructor DriverConstructor { get; }
Property Value#
TypeDescription
INetworkStreamDriverConstructor

HeartbeatTimeoutMS#

Timeout in milliseconds after which a heartbeat is sent if there is no activity.

Declaration#
public int HeartbeatTimeoutMS { get; set; }
Property Value#
TypeDescription
System.Int32

MaxConnectAttempts#

The maximum amount of connection attempts we will try before disconnecting.

Declaration#
public int MaxConnectAttempts { get; set; }
Property Value#
TypeDescription
System.Int32

MaxPacketQueueSize#

The maximum amount of packets that can be in the internal send/receive queues.

Declaration#
public int MaxPacketQueueSize { get; set; }
Property Value#
TypeDescription
System.Int32
Remarks#

Basically this is how many packets can be sent/received in a single update/frame.

MaxPayloadSize#

The maximum size of a payload that can be handled by the transport.

Declaration#
public int MaxPayloadSize { get; set; }
Property Value#
TypeDescription
System.Int32

MaxSendQueueSize#

The maximum size in bytes of the transport send queue.

Declaration#
public int MaxSendQueueSize { get; set; }
Property Value#
TypeDescription
System.Int32
Remarks#

The send queue accumulates messages for batching and stores messages when other internal send queues are full. If you routinely observe an error about too many in-flight packets, try increasing this.

Protocol#

Declaration#
public UnityTransport.ProtocolType Protocol { get; }
Property Value#
TypeDescription
UnityTransport.ProtocolType

ServerClientId#

Declaration#
public override ulong ServerClientId { get; }
Property Value#
TypeDescription
System.UInt64
Overrides#

NetworkTransport.ServerClientId

Methods#

CreateDriver(UnityTransport, out NetworkDriver, out NetworkPipeline, out NetworkPipeline, out NetworkPipeline)#

Declaration#
public void CreateDriver(UnityTransport transport, out NetworkDriver driver, out NetworkPipeline unreliableFragmentedPipeline, out NetworkPipeline unreliableSequencedFragmentedPipeline, out NetworkPipeline reliableSequencedPipeline)
Parameters#
TypeNameDescription
UnityTransporttransport
NetworkDriverdriver
NetworkPipelineunreliableFragmentedPipeline
NetworkPipelineunreliableSequencedFragmentedPipeline
NetworkPipelinereliableSequencedPipeline

DisconnectLocalClient()#

Declaration#
public override void DisconnectLocalClient()
Overrides#

NetworkTransport.DisconnectLocalClient()

DisconnectRemoteClient(UInt64)#

Declaration#
public override void DisconnectRemoteClient(ulong clientId)
Parameters#
TypeNameDescription
System.UInt64clientId
Overrides#

NetworkTransport.DisconnectRemoteClient(UInt64)

GetCurrentRtt(UInt64)#

Declaration#
public override ulong GetCurrentRtt(ulong clientId)
Parameters#
TypeNameDescription
System.UInt64clientId
Returns#
TypeDescription
System.UInt64
Overrides#

NetworkTransport.GetCurrentRtt(UInt64)

Initialize(NetworkManager)#

Declaration#
public override void Initialize(NetworkManager networkManager = null)
Parameters#
TypeNameDescription
NetworkManagernetworkManager
Overrides#

NetworkTransport.Initialize(NetworkManager)

PollEvent(out UInt64, out ArraySegment\<Byte>, out Single)#

Declaration#
public override NetworkEvent PollEvent(out ulong clientId, out ArraySegment<byte> payload, out float receiveTime)
Parameters#
TypeNameDescription
System.UInt64clientId
System.ArraySegment\<System.Byte>payload
System.SinglereceiveTime
Returns#
TypeDescription
NetworkEvent
Overrides#

NetworkTransport.PollEvent(out UInt64, out ArraySegment\<Byte>, out Single)

Send(UInt64, ArraySegment\<Byte>, NetworkDelivery)#

Declaration#
public override void Send(ulong clientId, ArraySegment<byte> payload, NetworkDelivery networkDelivery)
Parameters#
TypeNameDescription
System.UInt64clientId
System.ArraySegment\<System.Byte>payload
NetworkDeliverynetworkDelivery
Overrides#

NetworkTransport.Send(UInt64, ArraySegment\<Byte>, NetworkDelivery)

SetClientRelayData(String, UInt16, Byte[], Byte[], Byte[], Byte[], Boolean)#

Set the relay server data for the host.

Declaration#
public void SetClientRelayData(string ipAddress, ushort port, byte[] allocationId, byte[] key, byte[] connectionData, byte[] hostConnectionData, bool isSecure = false)
Parameters#
TypeNameDescription
System.StringipAddressIP address of the relay server.
System.UInt16portUDP port of the relay server.
System.Byte[]allocationIdAllocation ID as a byte array.
System.Byte[]keyAllocation key as a byte array.
System.Byte[]connectionDataConnection data as a byte array.
System.Byte[]hostConnectionDataHost's connection data as a byte array.
System.BooleanisSecureWhether the connection is secure (uses DTLS).

SetConnectionData(NetworkEndPoint, NetworkEndPoint)#

Sets IP and Port information. This will be ignored if using the Unity Relay and you should call SetRelayServerData(String, UInt16, Byte[], Byte[], Byte[], Byte[], Boolean)

Declaration#
public void SetConnectionData(NetworkEndPoint endPoint, NetworkEndPoint listenEndPoint = null)
Parameters#
TypeNameDescription
NetworkEndPointendPoint
NetworkEndPointlistenEndPoint

SetConnectionData(String, UInt16, String)#

Sets IP and Port information. This will be ignored if using the Unity Relay and you should call SetRelayServerData(String, UInt16, Byte[], Byte[], Byte[], Byte[], Boolean)

Declaration#
public void SetConnectionData(string ipv4Address, ushort port, string listenAddress = null)
Parameters#
TypeNameDescription
System.Stringipv4Address
System.UInt16port
System.StringlistenAddress

SetDebugSimulatorParameters(Int32, Int32, Int32)#

Set the parameters for the debug simulator.

Declaration#
public void SetDebugSimulatorParameters(int packetDelay, int packetJitter, int dropRate)
Parameters#
TypeNameDescription
System.Int32packetDelayPacket delay in milliseconds.
System.Int32packetJitterPacket jitter in milliseconds.
System.Int32dropRatePacket drop percentage.

SetHostRelayData(String, UInt16, Byte[], Byte[], Byte[], Boolean)#

Set the relay server data for the host.

Declaration#
public void SetHostRelayData(string ipAddress, ushort port, byte[] allocationId, byte[] key, byte[] connectionData, bool isSecure = false)
Parameters#
TypeNameDescription
System.StringipAddressIP address of the relay server.
System.UInt16portUDP port of the relay server.
System.Byte[]allocationIdAllocation ID as a byte array.
System.Byte[]keyAllocation key as a byte array.
System.Byte[]connectionDataConnection data as a byte array.
System.BooleanisSecureWhether the connection is secure (uses DTLS).

SetRelayServerData(String, UInt16, Byte[], Byte[], Byte[], Byte[], Boolean)#

Declaration#
public void SetRelayServerData(string ipv4Address, ushort port, byte[] allocationIdBytes, byte[] keyBytes, byte[] connectionDataBytes, byte[] hostConnectionDataBytes = null, bool isSecure = false)
Parameters#
TypeNameDescription
System.Stringipv4Address
System.UInt16port
System.Byte[]allocationIdBytes
System.Byte[]keyBytes
System.Byte[]connectionDataBytes
System.Byte[]hostConnectionDataBytes
System.BooleanisSecure

Shutdown()#

Declaration#
public override void Shutdown()
Overrides#

NetworkTransport.Shutdown()

StartClient()#

Declaration#
public override bool StartClient()
Returns#
TypeDescription
System.Boolean
Overrides#

NetworkTransport.StartClient()

StartServer()#

Declaration#
public override bool StartServer()
Returns#
TypeDescription
System.Boolean
Overrides#

NetworkTransport.StartServer()

Implements#

INetworkStreamDriverConstructor