Class NetworkManager
The main component of the library
Implements
Inherited Members
Namespace: Unity.Netcode
Assembly: solution.dll
Syntax
[AddComponentMenu("Netcode/Network Manager", -100)]
public class NetworkManager : MonoBehaviour, INetworkUpdateSystem
Fields
Name | Description |
---|---|
Log |
The log level to use |
Network |
The current netcode project configuration |
Pending |
Gets a dictionary of the clients that have been accepted by the transport but are still pending by the Netcode. This is only populated on the server. |
Run |
Gets or sets if the application should be set to run in background |
Server |
The client id used to represent the server |
Properties
Name | Description |
---|---|
Connected |
Gets a dictionary of connected clients and their clientId keys. This is only accessible on the server. |
Connected |
Gets a list of just the IDs of all connected clients. This is only accessible on the server. |
Connected |
Gets a list of connected clients. This is only accessible on the server. |
Connected |
The current host name we are connected to, used to validate certificate |
Connection |
The callback to invoke during connection approval. Allows client code to decide whether or not to allow incoming client connection |
Custom |
Gets the CustomMessagingManager for this NetworkManager |
Disconnect |
When disconnected from the server, the server may send a reason. If a reason was sent, this property will tell client code what the reason was. It should be queried after the OnClientDisconnectCallback is called |
Is |
Is true when the client has been approved. |
Is |
Gets Whether or not a client is running |
Is |
When true, the client is connected, approved, and synchronized with
the server.
Is |
Is |
Gets if we are running as host |
Is |
Is true when a server or host is listening for connections. Is true when a client is connecting or connected to a network session. Is false when not listening, connecting, or connected. |
Is |
Gets Whether or not a server is running |
Local |
Gets the local Network |
Local |
Returns ServerClientId if IsServer or LocalClientId if not |
Local |
The local Network |
Maximum |
Sets the maximum size of a message (or message batch) passed through the transport with the ReliableFragmented delivery. Warning: setting this value too low may result in the SDK becoming non-functional with projects that have a large number of NetworkBehaviours or NetworkVariables, as the SDK relies on the transport's ability to fragment some messages when they grow beyond the MTU size. |
Maximum |
Sets the maximum size of a single non-fragmented message (or message batch) passed through the transport. This should represent the transport's default MTU size, minus any transport-level overhead. This value will be used for any remote endpoints that haven't had per-endpoint MTUs set. This value is also used as the size of the temporary buffer used when serializing a single message (to avoid serializing multiple times when sending to multiple endpoints), and thus should be large enough to ensure it can hold each message type. This value defaults to 1296. |
Network |
Accessor property for the Network |
Network |
Accessor property for the Network |
Prefab |
The Network |
Scene |
The Network |
Server |
The Network |
Shutdown |
Can be used to determine if the Network |
Singleton | The singleton instance of the NetworkManager |
Spawn |
Gets the SpawnManager for this NetworkManager |
Methods
Name | Description |
---|---|
Add |
|
Disconnect |
Disconnects the remote client. |
Disconnect |
Disconnects the remote client. |
Get |
|
Get |
Queries the current MTU size for a client.
If no MTU has been set for that client, will return Maximum |
Network |
The update method that is being executed in the context of related Network |
Remove |
|
Set |
Set the maximum transmission unit for a specific peer.
This determines the maximum size of a message batch that can be sent to that client.
If not set for any given client, Maximum |
Set |
Set this NetworkManager instance as the static NetworkManager singleton |
Shutdown(bool) | Globally shuts down the library. Disconnects clients if connected and stops server if running. |
Start |
Starts a client |
Start |
Starts a Host |
Start |
Starts a server |
Events
Name | Description |
---|---|
On |
The callback to invoke once a client connects. This callback is only ran on the server and on the local client that connects. |
On |
The callback to invoke when a client disconnects. This callback is only ran on the server and on the local client that disconnects. |
On |
The callback to invoke once the local client is ready |
On |
The callback to invoke once the local client stops |
On |
This callback is invoked when the local server is started and listening for incoming connections. |
On |
This callback is invoked once the local server is stopped. |
On |
The callback to invoke if the Network |