category: Getting Started

The APIs used to handle incoming messages are very similar between the server and the client.

Peers send messages to a route when communicating with a remote scene. Often routes identify specific actions like "sending a chat message", "updating the player location" etc...

When writing code that handles incoming messages, you associate it with a specific route. Your code will be automatically executed by the runtime when the peer receives a message for this route.

Please note that even if routes are strings, these string are not sent in the actual messages. During the initial scene handshake, the peers will exchange 16bit route handles that will be used in place of the full route names. This solution limits considerably bandwidth consumption associated with message routing (it reduces routing data to 3 bytes, 1 for the scene handle, 2 for the route handle), but it limits the number of routes that can be declared on a single scene to 65536. That should be more than enough.


Route Handlers must be registered before calling Connect() so that the handles can be sent during handshake.

scene.AddRoute("ship.usedSkill", OnShipUsedSkill);


private void OnShipUsedSkill(Packet<IScenePeer> obj)
     var data = obj.ReadObject<MyParameterClass>();
     //Custom code


Route handlers must be registered in the scene template factory method before the first player connects to the scene.

 scene.AddRoute("position.update", OnPositionUpdate);

private void OnPositionUpdate(Packet<IScenePeerClient> packet)
      var data = packet.ReadObject<MyParameterClass>();

     //Custom code

Order: 7