DOTSNET comes with its own message protocol. While you will never have to worry about it, it is good to know when debugging or designing external applications.
Message IDs are automatically generated from the message's type name hash.
Receiving a NetworkMessage
Inherit from NetworkServerMessageSystem to handle a received message on the server:
Almost all server messages should require authentication. For example, a client that hasn’t logged in shouldn’t be able to send a player movement message.
Inherit from NetworkClientMessageSystem to handle a received message on the client:
using DOTSNET;
public class JoinWorldMessageSystem : NetworkServerMessageSystem<JoinWorldMessage>
{
protected override bool RequiresAuthentication() => true;
protected override void OnMessage(int connectionId, JoinWorldMessage message)
{
// handle the message
}
}
using DOTSNET;
public class MyMessageSystem : NetworkClientMessageSystem<MyMessage>
{
protected override void OnMessage(MyMessage message)
{
// handle the message
}
}