Version: 5.5

NetworkTransport

class in UnityEngine.Networking

Switch to Manual

Description

Transport Layer API.

Static Variables

IsStartedDeprecated.

Static Functions

AddHostCreates a host based on HostTopology.
AddHostWithSimulatorCreate a host and configure them to simulate Internet latency (works on Editor and development build only).
AddWebsocketHostCreated web socket host.
ConnectTries to establish a connection to another peer.
ConnectAsNetworkHostCreate dedicated connection to Relay server.
ConnectEndPointTry to establish connection to other peer, where the peer is specified using a C# System.EndPoint.
ConnectToNetworkPeerCreate a connection to another peer in the Relay group.
ConnectWithSimulatorConnect with simulated latency.
DisconnectSend a disconnect signal to the connected peer and close the connection. Poll NetworkTransport.Receive() to be notified that the connection is closed. This signal is only sent once (best effort delivery). If this packet is dropped for some reason, the peer closes the connection by timeout.
DisconnectNetworkHostThis will disconnect the host and disband the group. DisconnectNetworkHost can only be called by the group owner on the relay server.
FinishSendMulticastFinalizes sending of a message to a group of connections. Only one multicast message at a time is allowed per host.
GetAssetIdThe Unity Multiplayer spawning system uses assetIds to identify what remote objects to spawn. This function allows you to get the assetId for the prefab associated with an object.
GetBroadcastConnectionInfoAfter NetworkTransport.Receive() returns NetworkEventType.BroadcastEvent, this function will return the connection information of the broadcast sender. This information can then be used for connecting to the broadcast sender.
GetBroadcastConnectionMessageAfter NetworkTransport.Receive() returns NetworkEventType.BroadcastEvent, this function returns a complimentary message from the broadcast sender.
GetConnectionInfoReturns the connection parameters for the specified connectionId. These parameters can be sent to other users to establish a direct connection to this peer. If this peer is connected to the host via Relay, the Relay-related parameters are set.
GetCurrentIncomingMessageAmountReturns the number of unread messages in the read-queue.
GetCurrentOutgoingMessageAmountReturns the total number of messages still in the write-queue.
GetCurrentRttReturn the round trip time for the given connectionId.
GetNetIOTimeuSFunction returns time spent on network I/O operations in microseconds.
GetNetworkLostPacketNumReturn the total number of packets that has been lost.
GetNetworkTimestampGet a network timestamp. Can be used in your messages to investigate network delays together with Networking.GetRemoteDelayTimeMS.
GetPacketReceivedRateReturn the current receive rate in bytes per second.
GetPacketSentRateReturn the current send rate in bytes per second.
GetRemoteDelayTimeMSReturns the delay for the timestamp received.
InitInitializes the NetworkTransport. Should be called before any other operations on the NetworkTransport are done.
IsBroadcastDiscoveryRunningCheck if the broadcast discovery sender is running.
ReceiveCalled to poll the underlying system for events.
ReceiveFromHostSimilar to NetworkTransport.Receive but will only poll for the provided hostId.
ReceiveRelayEventFromHostPolls the host for the following events: NetworkEventType.ConnectEvent and NetworkEventType.DisconnectEvent. Can only be called by the relay group owner.
RemoveHostCloses the opened socket, and closes all connections belonging to that socket.
SendSend data to peer.
SendMulticastAdd a connection for the multicast send.
SetBroadcastCredentialsSets the credentials required for receiving broadcast messages. Should any credentials of a received broadcast message not match, the broadcast discovery message is dropped.
SetPacketStatUsed to inform the profiler of network packet statistics.
ShutdownShut down the NetworkTransport.
StartBroadcastDiscoveryStarts sending a broadcasting message in all local subnets.
StartSendMulticastStart to multicast send.
StopBroadcastDiscoveryStop sending the broadcast discovery message.