publicclassHelloServerMessage:Message{publicconstushortId=1;publicoverrideushortMessageId=> Id;publicstringContent;publicHelloServerMessage(stringcontent){this.Content =content;}publicHelloServerMessage(){// Empty constructor is for json deserialization}}
Smart message handler bindings
/*This code is client side*/staticvoidMain(string[]args){
ProtocolManager.Initialize(Assembly.GetAssembly(typeof(HelloMessage)), Assembly.GetExecutingAssembly());MyClientclient=new MyClient();
client.Connect("127.0.0.1",500);}publicclassMyClient:Client{// ...publicoverridevoidOnConnect(){
Console.WriteLine("Connected to server !");this.Send(new HelloMessage("Hi server!"));}}classMyMessagesHandlers{/* This code is server side. The method will be automatically invoked when receiving 'HelloMessage'. */[MessageHandler]publicstaticvoidHandleHelloMessage(HelloMessagemessage,MyClientclient){
Console.WriteLine(message.Content);// "Hi server!"}}