Mirror Networking
Mirror.Transport Class Referenceabstract

Abstract transport layer component More...

Inheritance diagram for Mirror.Transport:

Public Member Functions

abstract bool Available ()
 Is this transport available in the current platform?
 
abstract bool ClientConnected ()
 True if the client is currently connected to the server.
 
abstract void ClientConnect (string address)
 Connects the client to the server at the address.
 
virtual void ClientConnect (Uri uri)
 Connects the client to the server at the Uri. More...
 
abstract void ClientSend (ArraySegment< byte > segment, int channelId=Channels.Reliable)
 Sends a message to the server over the given channel.
 
abstract void ClientDisconnect ()
 Disconnects the client from the server
 
abstract Uri ServerUri ()
 Returns server address as Uri.
 
abstract bool ServerActive ()
 True if the server is currently listening for connections.
 
abstract void ServerStart ()
 Start listening for connections.
 
abstract void ServerSend (int connectionId, ArraySegment< byte > segment, int channelId=Channels.Reliable)
 Send a message to a client over the given channel.
 
abstract void ServerDisconnect (int connectionId)
 Disconnect a client from the server.
 
abstract string ServerGetClientAddress (int connectionId)
 Get a client's address on the server.
 
abstract void ServerStop ()
 Stop listening and disconnect all connections.
 
abstract int GetMaxPacketSize (int channelId=Channels.Reliable)
 Maximum message size for the given channel.
 
virtual int GetBatchThreshold (int channelId=Channels.Reliable)
 Recommended Batching threshold for this transport. More...
 
void Update ()
 
void LateUpdate ()
 
virtual void ClientEarlyUpdate ()
 NetworkLoop NetworkEarly/LateUpdate were added for a proper network update order. the goal is to: process_incoming() update_world() process_outgoing() in order to avoid unnecessary latency and data races. More...
 
virtual void ServerEarlyUpdate ()
 
virtual void ClientLateUpdate ()
 
virtual void ServerLateUpdate ()
 
abstract void Shutdown ()
 Shut down the transport, both as client and server
 
virtual void OnApplicationQuit ()
 Called by Unity when quitting. Inheriting Transports should call base for proper Shutdown. More...
 

Public Attributes

Action OnClientConnected
 Called by Transport when the client connected to the server. More...
 
Action< ArraySegment< byte >, int > OnClientDataReceived
 Called by Transport when the client received a message from the server. More...
 
Action< ArraySegment< byte >, int > OnClientDataSent
 Called by Transport when the client sent a message to the server. More...
 
Action< TransportError, string > OnClientError
 Called by Transport when the client encountered an error. More...
 
Action OnClientDisconnected
 Called by Transport when the client disconnected from the server. More...
 
Action< int > OnServerConnected
 Called by Transport when a new client connected to the server. More...
 
Action< int, ArraySegment< byte >, int > OnServerDataReceived
 Called by Transport when the server received a message from a client. More...
 
Action< int, ArraySegment< byte >, int > OnServerDataSent
 Called by Transport when the server sent a message to a client. More...
 
Action< int, TransportError, string > OnServerError
 Called by Transport when a server's connection encountered a problem. More...
 
Action< int > OnServerDisconnected
 Called by Transport when a client disconnected from the server. More...
 

Static Public Attributes

static Transport activeTransport
 The current transport used by Mirror. More...
 

Detailed Description

Abstract transport layer component

Definition at line 31 of file Transport.cs.

Member Function Documentation

◆ ClientConnect()

virtual void Mirror.Transport.ClientConnect ( Uri  uri)
virtual

Connects the client to the server at the Uri.

Definition at line 89 of file Transport.cs.

90 {
91 // By default, to keep backwards compatibility, just connect to the host
92 // in the uri
93 ClientConnect(uri.Host);
94 }
abstract void ClientConnect(string address)
Connects the client to the server at the address.

◆ ClientEarlyUpdate()

virtual void Mirror.Transport.ClientEarlyUpdate ( )
virtual

NetworkLoop NetworkEarly/LateUpdate were added for a proper network update order. the goal is to: process_incoming() update_world() process_outgoing() in order to avoid unnecessary latency and data races.

Definition at line 174 of file Transport.cs.

174{}

◆ ClientLateUpdate()

virtual void Mirror.Transport.ClientLateUpdate ( )
virtual

Definition at line 176 of file Transport.cs.

176{}

◆ GetBatchThreshold()

virtual int Mirror.Transport.GetBatchThreshold ( int  channelId = Channels.Reliable)
virtual

Recommended Batching threshold for this transport.

Definition at line 140 of file Transport.cs.

141 {
142 return GetMaxPacketSize(channelId);
143 }
abstract int GetMaxPacketSize(int channelId=Channels.Reliable)
Maximum message size for the given channel.

◆ LateUpdate()

void Mirror.Transport.LateUpdate ( )

Definition at line 159 of file Transport.cs.

159{}

◆ OnApplicationQuit()

virtual void Mirror.Transport.OnApplicationQuit ( )
virtual

Called by Unity when quitting. Inheriting Transports should call base for proper Shutdown.

Definition at line 183 of file Transport.cs.

184 {
185 // stop transport (e.g. to shut down threads)
186 // (when pressing Stop in the Editor, Unity keeps threads alive
187 // until we press Start again. so if Transports use threads, we
188 // really want them to end now and not after next start)
189 Shutdown();
190 }
abstract void Shutdown()
Shut down the transport, both as client and server

◆ ServerEarlyUpdate()

virtual void Mirror.Transport.ServerEarlyUpdate ( )
virtual

Definition at line 175 of file Transport.cs.

175{}

◆ ServerLateUpdate()

virtual void Mirror.Transport.ServerLateUpdate ( )
virtual

Definition at line 177 of file Transport.cs.

177{}

◆ Update()

void Mirror.Transport.Update ( )

Definition at line 158 of file Transport.cs.

158{}

Member Data Documentation

◆ activeTransport

Transport Mirror.Transport.activeTransport
static

The current transport used by Mirror.

Definition at line 35 of file Transport.cs.

◆ OnClientConnected

Action Mirror.Transport.OnClientConnected

Called by Transport when the client connected to the server.

Definition at line 42 of file Transport.cs.

◆ OnClientDataReceived

Action<ArraySegment<byte>, int> Mirror.Transport.OnClientDataReceived

Called by Transport when the client received a message from the server.

Definition at line 45 of file Transport.cs.

◆ OnClientDataSent

Action<ArraySegment<byte>, int> Mirror.Transport.OnClientDataSent

Called by Transport when the client sent a message to the server.

Definition at line 52 of file Transport.cs.

◆ OnClientDisconnected

Action Mirror.Transport.OnClientDisconnected

Called by Transport when the client disconnected from the server.

Definition at line 58 of file Transport.cs.

◆ OnClientError

Action<TransportError, string> Mirror.Transport.OnClientError

Called by Transport when the client encountered an error.

Definition at line 55 of file Transport.cs.

◆ OnServerConnected

Action<int> Mirror.Transport.OnServerConnected

Called by Transport when a new client connected to the server.

Definition at line 62 of file Transport.cs.

◆ OnServerDataReceived

Action<int, ArraySegment<byte>, int> Mirror.Transport.OnServerDataReceived

Called by Transport when the server received a message from a client.

Definition at line 65 of file Transport.cs.

◆ OnServerDataSent

Action<int, ArraySegment<byte>, int> Mirror.Transport.OnServerDataSent

Called by Transport when the server sent a message to a client.

Definition at line 72 of file Transport.cs.

◆ OnServerDisconnected

Action<int> Mirror.Transport.OnServerDisconnected

Called by Transport when a client disconnected from the server.

Definition at line 79 of file Transport.cs.

◆ OnServerError

Action<int, TransportError, string> Mirror.Transport.OnServerError

Called by Transport when a server's connection encountered a problem.

If a Disconnect will also be raised, raise the Error first.

Definition at line 76 of file Transport.cs.