Mirror::MultiplexTransport
Inherits from Transport, MonoBehaviour
Public Functions
Name | |
---|---|
void | Awake() |
virtual override bool | Available() Is this transport available in the current platform? |
virtual override void | ClientConnect(string address) Establish a connection to a server |
virtual override void | ClientConnect(Uri uri) Establish a connection to a server |
virtual override bool | ClientConnected() Determines if we are currently connected to the server |
virtual override void | ClientDisconnect() Disconnect this client from the server |
virtual override void | ClientSend(int channelId, ArraySegment< byte > segment) Send data to the server |
virtual override Uri | ServerUri() Retrieves the address of this server. Useful for network discovery |
virtual override bool | ServerActive() Determines if the server is up and running |
virtual override string | ServerGetClientAddress(int connectionId) Get the client address |
virtual override bool | ServerDisconnect(int connectionId) Disconnect a client from this server. Useful to kick people out. |
virtual override void | ServerSend(int connectionId, int channelId, ArraySegment< byte > segment) Send data to a client. |
virtual override void | ServerStart() Start listening for clients |
virtual override void | ServerStop() Stop listening for clients and disconnect all existing clients |
virtual override int | GetMaxPacketSize(int channelId =0) The maximum packet size for a given channel. Unreliable transports usually can only deliver small packets. Reliable fragmented channels can usually deliver large ones. |
virtual override void | Shutdown() Shut down the transport, both as client and server |
override string | ToString() |
Public Attributes
Name | |
---|---|
Transport [] | transports |
Additional inherited members
Public Functions inherited from Transport
Name | |
---|---|
void | Update() |
virtual void | OnApplicationQuit() called when quitting the application by closing the window / pressing stop in the editor |
Public Attributes inherited from Transport
Name | |
---|---|
Transport | activeTransport The current transport used by Mirror. |
UnityEvent | OnClientConnected Notify subscribers when when this client establish a successful connection to the server |
ClientDataReceivedEvent | OnClientDataReceived Notify subscribers when this client receive data from the server |
UnityEventException | OnClientError Notify subscribers when this client encounters an error communicating with the server |
UnityEvent | OnClientDisconnected Notify subscribers when this client disconnects from the server |
UnityEventInt | OnServerConnected Notify subscribers when a client connects to this server |
ServerDataReceivedEvent | OnServerDataReceived Notify subscribers when this server receives data from the client |
UnityEventIntException | OnServerError Notify subscribers when this server has some problem communicating with the client |
UnityEventInt | OnServerDisconnected Notify subscribers when a client disconnects from this server |
Public Functions Documentation
function Awake
inline void Awake()
function Available
inline virtual override bool Available()
Is this transport available in the current platform?
Return: True if this transport works in the current platform
Reimplements: Mirror::Transport::Available
Some transports might only be available in mobile
Many will not work in webgl
Example usage: return Application.platform == RuntimePlatform.WebGLPlayer
function ClientConnect
inline virtual override void ClientConnect(
string address
)
Establish a connection to a server
Parameters:
- address The IP address or FQDN of the server we are trying to connect to
Reimplements: Mirror::Transport::ClientConnect
function ClientConnect
inline virtual override void ClientConnect(
Uri uri
)
Establish a connection to a server
Parameters:
- uri The address of the server we are trying to connect to
Reimplements: Mirror::Transport::ClientConnect
function ClientConnected
inline virtual override bool ClientConnected()
Determines if we are currently connected to the server
Return: True if a connection has been established to the server
Reimplements: Mirror::Transport::ClientConnected
function ClientDisconnect
inline virtual override void ClientDisconnect()
Disconnect this client from the server
Reimplements: Mirror::Transport::ClientDisconnect
function ClientSend
inline virtual override void ClientSend(
int channelId,
ArraySegment< byte > segment
)
Send data to the server
Parameters:
- channelId The channel to use. 0 is the default channel, but some transports might want to provide unreliable, encrypted, compressed, or any other feature as new channels
- segment The data to send to the server. Will be recycled after returning, so either use it directly or copy it internally. This allows for allocation-free sends!
Reimplements: Mirror::Transport::ClientSend
function ServerUri
inline virtual override Uri ServerUri()
Retrieves the address of this server. Useful for network discovery
Return: the url at which this server can be reached
Reimplements: Mirror::Transport::ServerUri
function ServerActive
inline virtual override bool ServerActive()
Determines if the server is up and running
Return: true if the transport is ready for connections from clients
Reimplements: Mirror::Transport::ServerActive
function ServerGetClientAddress
inline virtual override string ServerGetClientAddress(
int connectionId
)
Get the client address
Parameters:
- connectionId id of the client
Return: address of the client
Reimplements: Mirror::Transport::ServerGetClientAddress
function ServerDisconnect
inline virtual override bool ServerDisconnect(
int connectionId
)
Disconnect a client from this server. Useful to kick people out.
Parameters:
- connectionId the id of the client to disconnect
Return: true if the client was kicked
Reimplements: Mirror::Transport::ServerDisconnect
function ServerSend
inline virtual override void ServerSend(
int connectionId,
int channelId,
ArraySegment< byte > segment
)
Send data to a client.
Parameters:
- connectionId The client connection id to send the data to
- channelId The channel to be used. Transports can use channels to implement other features such as unreliable, encryption, compression, etc...
- data
Reimplements: Mirror::Transport::ServerSend
function ServerStart
inline virtual override void ServerStart()
Start listening for clients
Reimplements: Mirror::Transport::ServerStart
function ServerStop
inline virtual override void ServerStop()
Stop listening for clients and disconnect all existing clients
Reimplements: Mirror::Transport::ServerStop
function GetMaxPacketSize
inline virtual override int GetMaxPacketSize(
int channelId =0
)
The maximum packet size for a given channel. Unreliable transports usually can only deliver small packets. Reliable fragmented channels can usually deliver large ones.
Parameters:
- channelId channel id
Return: the size in bytes that can be sent via the provided channel
Reimplements: Mirror::Transport::GetMaxPacketSize
GetMaxPacketSize needs to return a value at all times. Even if the Transport isn't running, or isn't Available(). This is because Fallback and Multiplex transports need to find the smallest possible packet size at runtime.
function Shutdown
inline virtual override void Shutdown()
Shut down the transport, both as client and server
Reimplements: Mirror::Transport::Shutdown
function ToString
inline override string ToString()
Public Attributes Documentation
variable transports
Transport [] transports;
Updated on 25 January 2021 at 09:57:16 UTC