Class NetworkServer
NetworkServer handles remote connections and has a local connection for a local client.
Inheritance
NetworkServer
Assembly: doc.dll
Syntax
public static class NetworkServer : object
Fields
|
Improve this Doc
View Source
aoi
Declaration
public static InterestManagement aoi
Field Value
|
Improve this Doc
View Source
connections
Dictionary of all server connections, with connectionId as key
Declaration
public static Dictionary<int, NetworkConnectionToClient> connections
Field Value
|
Improve this Doc
View Source
dontListen
Single player mode can use dontListen to not accept incoming connections
Declaration
public static bool dontListen
Field Value
|
Improve this Doc
View Source
isLoadingScene
Declaration
public static bool isLoadingScene
Field Value
|
Improve this Doc
View Source
maxConnections
Declaration
public static int maxConnections
Field Value
|
Improve this Doc
View Source
OnConnectedEvent
Declaration
public static Action<NetworkConnectionToClient> OnConnectedEvent
Field Value
|
Improve this Doc
View Source
OnDisconnectedEvent
Declaration
public static Action<NetworkConnectionToClient> OnDisconnectedEvent
Field Value
|
Improve this Doc
View Source
OnErrorEvent
Declaration
public static Action<NetworkConnectionToClient, TransportError, string> OnErrorEvent
Field Value
|
Improve this Doc
View Source
spawned
All spawned NetworkIdentities by netId.
Declaration
public static readonly Dictionary<uint, NetworkIdentity> spawned
Field Value
Properties
|
Improve this Doc
View Source
active
active checks if the server has been started
Declaration
public static bool active { get; }
Property Value
|
Improve this Doc
View Source
localClientActive
True is a local client is currently active on the server
Declaration
public static bool localClientActive { get; }
Property Value
|
Improve this Doc
View Source
localConnection
Connection to host mode client (if any)
Declaration
public static NetworkConnectionToClient localConnection { get; }
Property Value
Methods
|
Improve this Doc
View Source
ActivateHostScene()
Declaration
public static void ActivateHostScene()
|
Improve this Doc
View Source
AddConnection(NetworkConnectionToClient)
Add a connection and setup callbacks. Returns true if not added yet.
Declaration
public static bool AddConnection(NetworkConnectionToClient conn)
Parameters
Returns
|
Improve this Doc
View Source
AddPlayerForConnection(NetworkConnectionToClient, GameObject)
Called by server after AddPlayer message to add the player for the connection.
Declaration
public static bool AddPlayerForConnection(NetworkConnectionToClient conn, GameObject player)
Parameters
Returns
|
Improve this Doc
View Source
AddPlayerForConnection(NetworkConnectionToClient, GameObject, Guid)
Called by server after AddPlayer message to add the player for the connection.
Declaration
public static bool AddPlayerForConnection(NetworkConnectionToClient conn, GameObject player, Guid assetId)
Parameters
Returns
|
Improve this Doc
View Source
ClearHandlers()
Clears all registered message handlers.
Declaration
public static void ClearHandlers()
|
Improve this Doc
View Source
Destroy(GameObject)
Destroys this object and corresponding objects on all clients.
Declaration
public static void Destroy(GameObject obj)
Parameters
Type |
Name |
Description |
GameObject |
obj |
|
|
Improve this Doc
View Source
DestroyPlayerForConnection(NetworkConnectionToClient)
Destroys all of the connection's owned objects on the server.
Declaration
public static void DestroyPlayerForConnection(NetworkConnectionToClient conn)
Parameters
|
Improve this Doc
View Source
DisconnectAll()
Disconnect all connections, including the local connection.
Declaration
public static void DisconnectAll()
|
Improve this Doc
View Source
HasExternalConnections()
True if we have external connections (that are not host)
Declaration
public static bool HasExternalConnections()
Returns
|
Improve this Doc
View Source
Listen(Int32)
Starts server and listens to incoming connections with max connections limit.
Declaration
public static void Listen(int maxConns)
Parameters
Type |
Name |
Description |
Int32 |
maxConns |
|
|
Improve this Doc
View Source
RebuildObservers(NetworkIdentity, Boolean)
Declaration
public static void RebuildObservers(NetworkIdentity identity, bool initialize)
Parameters
|
Improve this Doc
View Source
RegisterHandler<T>(Action<NetworkConnectionToClient, T, Int32>, Boolean)
Register a handler for message type T. Most should require authentication.
Declaration
public static void RegisterHandler<T>(Action<NetworkConnectionToClient, T, int> handler, bool requireAuthentication = true)
where T : struct, NetworkMessage
Parameters
Type Parameters
|
Improve this Doc
View Source
RegisterHandler<T>(Action<NetworkConnectionToClient, T>, Boolean)
Register a handler for message type T. Most should require authentication.
Declaration
public static void RegisterHandler<T>(Action<NetworkConnectionToClient, T> handler, bool requireAuthentication = true)
where T : struct, NetworkMessage
Parameters
Type Parameters
|
Improve this Doc
View Source
RemoveConnection(Int32)
Removes a connection by connectionId. Returns true if removed.
Declaration
public static bool RemoveConnection(int connectionId)
Parameters
Type |
Name |
Description |
Int32 |
connectionId |
|
Returns
|
Improve this Doc
View Source
RemovePlayerForConnection(NetworkConnection, Boolean)
Removes the player object from the connection
Declaration
public static void RemovePlayerForConnection(NetworkConnection conn, bool destroyServerObject)
Parameters
|
Improve this Doc
View Source
ReplaceHandler<T>(Action<T>, Boolean)
Replace a handler for message type T. Most should require authentication.
Declaration
public static void ReplaceHandler<T>(Action<T> handler, bool requireAuthentication = true)
where T : struct, NetworkMessage
Parameters
Type |
Name |
Description |
Action<T> |
handler |
|
Boolean |
requireAuthentication |
|
Type Parameters
|
Improve this Doc
View Source
ReplaceHandler<T>(Action<NetworkConnectionToClient, T>, Boolean)
Replace a handler for message type T. Most should require authentication.
Declaration
public static void ReplaceHandler<T>(Action<NetworkConnectionToClient, T> handler, bool requireAuthentication = true)
where T : struct, NetworkMessage
Parameters
Type Parameters
|
Improve this Doc
View Source
ReplacePlayerForConnection(NetworkConnectionToClient, GameObject, Guid, Boolean)
Replaces connection's player object. The old object is not destroyed.
Declaration
public static bool ReplacePlayerForConnection(NetworkConnectionToClient conn, GameObject player, Guid assetId, bool keepAuthority = false)
Parameters
Returns
|
Improve this Doc
View Source
ReplacePlayerForConnection(NetworkConnectionToClient, GameObject, Boolean)
Replaces connection's player object. The old object is not destroyed.
Declaration
public static bool ReplacePlayerForConnection(NetworkConnectionToClient conn, GameObject player, bool keepAuthority = false)
Parameters
Returns
|
Improve this Doc
View Source
SendToAll<T>(T, Int32, Boolean)
Send a message to all clients, even those that haven't joined the world yet (non ready)
Declaration
public static void SendToAll<T>(T message, int channelId = null, bool sendToReadyOnly = false)
where T : struct, NetworkMessage
Parameters
Type |
Name |
Description |
T |
message |
|
Int32 |
channelId |
|
Boolean |
sendToReadyOnly |
|
Type Parameters
|
Improve this Doc
View Source
SendToReady<T>(T, Int32)
Send a message to all clients which have joined the world (are ready).
Declaration
public static void SendToReady<T>(T message, int channelId = null)
where T : struct, NetworkMessage
Parameters
Type |
Name |
Description |
T |
message |
|
Int32 |
channelId |
|
Type Parameters
|
Improve this Doc
View Source
SendToReadyObservers<T>(NetworkIdentity, T, Boolean, Int32)
Send a message to only clients which are ready with option to include the owner of the object identity
Declaration
public static void SendToReadyObservers<T>(NetworkIdentity identity, T message, bool includeOwner = true, int channelId = null)
where T : struct, NetworkMessage
Parameters
Type Parameters
|
Improve this Doc
View Source
SendToReadyObservers<T>(NetworkIdentity, T, Int32)
Send a message to only clients which are ready including the owner of the NetworkIdentity
Declaration
public static void SendToReadyObservers<T>(NetworkIdentity identity, T message, int channelId)
where T : struct, NetworkMessage
Parameters
Type Parameters
|
Improve this Doc
View Source
SetAllClientsNotReady()
Marks all connected clients as no longer ready.
Declaration
public static void SetAllClientsNotReady()
|
Improve this Doc
View Source
SetClientNotReady(NetworkConnectionToClient)
Marks the client of the connection to be not-ready.
Declaration
public static void SetClientNotReady(NetworkConnectionToClient conn)
Parameters
|
Improve this Doc
View Source
SetClientReady(NetworkConnectionToClient)
Flags client connection as ready (=joined world).
Declaration
public static void SetClientReady(NetworkConnectionToClient conn)
Parameters
|
Improve this Doc
View Source
Shutdown()
Shuts down the server and disconnects all clients
Declaration
public static void Shutdown()
|
Improve this Doc
View Source
Spawn(GameObject, GameObject)
Spawns an object and also assigns Client Authority to the specified client.
Declaration
public static void Spawn(GameObject obj, GameObject ownerPlayer)
Parameters
Type |
Name |
Description |
GameObject |
obj |
|
GameObject |
ownerPlayer |
|
|
Improve this Doc
View Source
Spawn(GameObject, Guid, NetworkConnection)
Spawns an object and also assigns Client Authority to the specified client.
Declaration
public static void Spawn(GameObject obj, Guid assetId, NetworkConnection ownerConnection = null)
Parameters
|
Improve this Doc
View Source
Spawn(GameObject, NetworkConnection)
Spawn the given game object on all clients which are ready.
Declaration
public static void Spawn(GameObject obj, NetworkConnection ownerConnection = null)
Parameters
|
Improve this Doc
View Source
SpawnObjects()
Spawns NetworkIdentities in the scene on the server.
Declaration
public static bool SpawnObjects()
Returns
|
Improve this Doc
View Source
UnregisterHandler<T>()
Unregister a handler for a message type T.
Declaration
public static void UnregisterHandler<T>()
where T : struct, NetworkMessage
Type Parameters
|
Improve this Doc
View Source
UnSpawn(GameObject)
This takes an object that has been spawned and un-spawns it.
Declaration
public static void UnSpawn(GameObject obj)
Parameters
Type |
Name |
Description |
GameObject |
obj |
|