Mirror Networking
|
NetworkServer handles remote connections and has a local connection for a local client. More...
Static Public Member Functions | |
static void | ActivateHostScene () |
static void | Listen (int maxConns) |
Starts server and listens to incoming connections with max connections limit. More... | |
static void | Shutdown () |
Shuts down the server and disconnects all clients More... | |
static bool | AddConnection (NetworkConnectionToClient conn) |
Add a connection and setup callbacks. Returns true if not added yet. More... | |
static bool | RemoveConnection (int connectionId) |
Removes a connection by connectionId. Returns true if removed. | |
static bool | HasExternalConnections () |
True if we have external connections (that are not host) More... | |
static void | SendToAll< T > (T message, int channelId=Channels.Reliable, bool sendToReadyOnly=false) |
Send a message to all clients, even those that haven't joined the world yet (non ready) More... | |
static void | SendToReady< T > (T message, int channelId=Channels.Reliable) |
Send a message to all clients which have joined the world (are ready). More... | |
static void | SendToReadyObservers< T > (NetworkIdentity identity, T message, bool includeOwner=true, int channelId=Channels.Reliable) |
Send a message to only clients which are ready with option to include the owner of the object identity More... | |
static void | SendToReadyObservers< T > (NetworkIdentity identity, T message, int channelId) |
Send a message to only clients which are ready including the owner of the NetworkIdentity More... | |
static void | RegisterHandler< T > (Action< NetworkConnectionToClient, T > handler, bool requireAuthentication=true) |
Register a handler for message type T. Most should require authentication. More... | |
static void | RegisterHandler< T > (Action< NetworkConnectionToClient, T, int > handler, bool requireAuthentication=true) |
Register a handler for message type T. Most should require authentication. More... | |
static void | ReplaceHandler< T > (Action< NetworkConnectionToClient, T > handler, bool requireAuthentication=true) |
Replace a handler for message type T. Most should require authentication. More... | |
static void | ReplaceHandler< T > (Action< T > handler, bool requireAuthentication=true) |
Replace a handler for message type T. Most should require authentication. More... | |
static void | UnregisterHandler< T > () |
Unregister a handler for a message type T. More... | |
static void | ClearHandlers () |
Clears all registered message handlers. | |
static void | DisconnectAll () |
Disconnect all connections, including the local connection. More... | |
static bool | AddPlayerForConnection (NetworkConnectionToClient conn, GameObject player) |
Called by server after AddPlayer message to add the player for the connection. More... | |
static bool | AddPlayerForConnection (NetworkConnectionToClient conn, GameObject player, Guid assetId) |
Called by server after AddPlayer message to add the player for the connection. More... | |
static bool | ReplacePlayerForConnection (NetworkConnectionToClient conn, GameObject player, bool keepAuthority=false) |
Replaces connection's player object. The old object is not destroyed. More... | |
static bool | ReplacePlayerForConnection (NetworkConnectionToClient conn, GameObject player, Guid assetId, bool keepAuthority=false) |
Replaces connection's player object. The old object is not destroyed. More... | |
static void | SetClientReady (NetworkConnectionToClient conn) |
Flags client connection as ready (=joined world). More... | |
static void | SetClientNotReady (NetworkConnectionToClient conn) |
Marks the client of the connection to be not-ready. More... | |
static void | SetAllClientsNotReady () |
Marks all connected clients as no longer ready. More... | |
static void | RemovePlayerForConnection (NetworkConnection conn, bool destroyServerObject) |
Removes the player object from the connection More... | |
static void | Spawn (GameObject obj, NetworkConnection ownerConnection=null) |
Spawn the given game object on all clients which are ready. More... | |
static void | Spawn (GameObject obj, GameObject ownerPlayer) |
Spawns an object and also assigns Client Authority to the specified client. More... | |
static void | Spawn (GameObject obj, Guid assetId, NetworkConnection ownerConnection=null) |
Spawns an object and also assigns Client Authority to the specified client. More... | |
static bool | SpawnObjects () |
Spawns NetworkIdentities in the scene on the server. More... | |
static void | UnSpawn (GameObject obj) |
This takes an object that has been spawned and un-spawns it. | |
static void | DestroyPlayerForConnection (NetworkConnectionToClient conn) |
Destroys all of the connection's owned objects on the server. More... | |
static void | Destroy (GameObject obj) |
Destroys this object and corresponding objects on all clients. | |
static void | RebuildObservers (NetworkIdentity identity, bool initialize) |
Static Public Attributes | |
static int | maxConnections |
static Dictionary< int, NetworkConnectionToClient > | connections |
Dictionary of all server connections, with connectionId as key More... | |
static readonly Dictionary< uint, NetworkIdentity > | spawned |
All spawned NetworkIdentities by netId. More... | |
static bool | dontListen |
Single player mode can use dontListen to not accept incoming connections More... | |
static bool | isLoadingScene |
static InterestManagement | aoi |
static Action< NetworkConnectionToClient > | OnConnectedEvent |
static Action< NetworkConnectionToClient > | OnDisconnectedEvent |
static Action< NetworkConnectionToClient, TransportError, string > | OnErrorEvent |
Properties | |
static NetworkConnectionToClient | localConnection [get] |
Connection to host mode client (if any) More... | |
static bool | localClientActive [get] |
True is a local client is currently active on the server More... | |
static bool | active [get, set] |
active checks if the server has been started More... | |
NetworkServer handles remote connections and has a local connection for a local client.
Definition at line 10 of file NetworkServer.cs.
|
static |
Definition at line 101 of file NetworkServer.cs.
|
static |
Add a connection and setup callbacks. Returns true if not added yet.
Definition at line 226 of file NetworkServer.cs.
|
static |
Called by server after AddPlayer message to add the player for the connection.
Definition at line 716 of file NetworkServer.cs.
|
static |
Called by server after AddPlayer message to add the player for the connection.
Definition at line 762 of file NetworkServer.cs.
|
static |
Destroys all of the connection's owned objects on the server.
Definition at line 1290 of file NetworkServer.cs.
|
static |
Disconnect all connections, including the local connection.
Definition at line 672 of file NetworkServer.cs.
|
static |
True if we have external connections (that are not host)
Definition at line 268 of file NetworkServer.cs.
|
static |
Starts server and listens to incoming connections with max connections limit.
Definition at line 121 of file NetworkServer.cs.
|
static |
Definition at line 1554 of file NetworkServer.cs.
|
static |
Register a handler for message type T. Most should require authentication.
T | : | struct | |
T | : | NetworkMessage |
Definition at line 608 of file NetworkServer.cs.
|
static |
Register a handler for message type T. Most should require authentication.
T | : | struct | |
T | : | NetworkMessage |
Definition at line 621 of file NetworkServer.cs.
|
static |
Removes the player object from the connection
Definition at line 912 of file NetworkServer.cs.
|
static |
Replace a handler for message type T. Most should require authentication.
T | : | struct | |
T | : | NetworkMessage |
Definition at line 633 of file NetworkServer.cs.
|
static |
Replace a handler for message type T. Most should require authentication.
T | : | struct | |
T | : | NetworkMessage |
Definition at line 641 of file NetworkServer.cs.
|
static |
Replaces connection's player object. The old object is not destroyed.
Definition at line 774 of file NetworkServer.cs.
|
static |
Replaces connection's player object. The old object is not destroyed.
Definition at line 835 of file NetworkServer.cs.
|
static |
Send a message to all clients, even those that haven't joined the world yet (non ready)
T | : | struct | |
T | : | NetworkMessage |
Definition at line 285 of file NetworkServer.cs.
|
static |
Send a message to all clients which have joined the world (are ready).
T | : | struct | |
T | : | NetworkMessage |
Definition at line 320 of file NetworkServer.cs.
|
static |
Send a message to only clients which are ready with option to include the owner of the object identity
T | : | struct | |
T | : | NetworkMessage |
Definition at line 358 of file NetworkServer.cs.
|
static |
Send a message to only clients which are ready including the owner of the NetworkIdentity
T | : | struct | |
T | : | NetworkMessage |
Definition at line 388 of file NetworkServer.cs.
|
static |
Marks all connected clients as no longer ready.
Definition at line 879 of file NetworkServer.cs.
|
static |
Marks the client of the connection to be not-ready.
Definition at line 868 of file NetworkServer.cs.
|
static |
Flags client connection as ready (=joined world).
Definition at line 852 of file NetworkServer.cs.
|
static |
Shuts down the server and disconnects all clients
Definition at line 171 of file NetworkServer.cs.
|
static |
Spawns an object and also assigns Client Authority to the specified client.
Definition at line 1107 of file NetworkServer.cs.
|
static |
Spawns an object and also assigns Client Authority to the specified client.
Definition at line 1127 of file NetworkServer.cs.
|
static |
Spawn the given game object on all clients which are ready.
Definition at line 1100 of file NetworkServer.cs.
|
static |
Spawns NetworkIdentities in the scene on the server.
Definition at line 1155 of file NetworkServer.cs.
|
static |
Unregister a handler for a message type T.
T | : | struct | |
T | : | NetworkMessage |
Definition at line 648 of file NetworkServer.cs.
|
static |
Definition at line 46 of file NetworkServer.cs.
|
static |
Dictionary of all server connections, with connectionId as key
Definition at line 22 of file NetworkServer.cs.
|
static |
Single player mode can use dontListen to not accept incoming connections
Definition at line 36 of file NetworkServer.cs.
|
static |
Definition at line 42 of file NetworkServer.cs.
|
static |
Definition at line 13 of file NetworkServer.cs.
|
static |
Definition at line 53 of file NetworkServer.cs.
|
static |
Definition at line 54 of file NetworkServer.cs.
|
static |
Definition at line 55 of file NetworkServer.cs.
|
static |
All spawned NetworkIdentities by netId.
Definition at line 31 of file NetworkServer.cs.
|
staticgetset |
active checks if the server has been started
Definition at line 39 of file NetworkServer.cs.
|
staticget |
True is a local client is currently active on the server
Definition at line 19 of file NetworkServer.cs.
|
staticget |
Connection to host mode client (if any)
Definition at line 16 of file NetworkServer.cs.