D
D
DOTSNET
Search…
NetworkServerSystem
NetworkServerSystem is the main server class, found in ServerWorld.
NetworkServerSystemAuthoring can be used to interact with it from the Inspector. In the example scene, the NetworkServer scene object has the authoring component:

NetworkServerSystem API

Property:
Description:
state
Current server state (active/inactive).
startIfHeadless
Auto start the server in Linux headless mode.
isHeadless
True if the server is running in Linux headless mode.
tickRate
Tick rate for all systems in the ServerActiveSimulationSystemGroup in Hz.
connectionLimit
Maximum amount of allowed player connections.
connections
All connected connections by connectionId.
spawned
All spawned Entities by netId.
Function:
Description:
StartServer()
Start listening to incoming connections.
StopServer()
Stop listening to incoming connections.
Disconnect(connectionId)
Disconnect a connection by connectionId.
Send(message, connectionId, channel)
Send a NetworkMessage to a connection.
Some transports support different channels.
If in doubt, leave the channel at default = Reliable.
OnConnected(connectionId)
Virtual function for classes that inherit from NetworkServerSystem.
OnDisconnected(connectionId)
Virtual function for classes that inherit from NetworkServerSystem.
RegisterHandler<T>(handler, requiresAuthentication)
Register a handler for an incoming message. Inheriting from NetworkServerMessageSystem registers it automatically.
All messages except the handshake/login should require authentication.
NOTE: custom allocator for the new NetworkMessage<T> can be passed as third parameter in case a system wants to reuse large messages like WorldStateMessage instead of allocating each time.
UnregisterHandler<T>
Unregister handler for the NetworkMessage type.
Spawn(Entity, ownerConnectionid)
Spawn an instantiated Entity in the world and let all clients know about it. Entity needs to have a NetworkEntity component.
Use ownerConnection if it’s owned by a connection, e.g. player/player’s pet.
Unspawn(Entity)
Unspawn the Entity from the world and let all clients know about it.
Destroy(Entity)
Unspawn and then Destroy an Entity. This is for convenience.
JoinWorld(connectionId, Entity)
Each game will handle their own character/team/race selection. Afterwards call JoinWorld with the selected player Entity to get started.
This flags the connection as joinedWorld.
Last modified 18d ago
Copy link