Exemple #1
0
 public IMessage ToMessage(IMessagable obj)
 {
     IMessage message = BaseResolver.ToMessage(obj);
       var textMessage = new TextMessage(message.Header, message.Content);
       if (textMessage.Content.Length > DefaultCompressionThreshold)
       {
     textMessage.Content = "c" + CompressMessage(textMessage.Content);
       }
       else
       {
     textMessage.Content = "u" + textMessage.Content;
       }
       return textMessage;
 }
Exemple #2
0
 public IMessagable GetMessageObject(IMessage message)
 {
     var textMessage = new TextMessage(message.Header, message.Content);
       if (textMessage.Content.StartsWith("c"))//这...
       {
     textMessage.Content = DecompressMessage(textMessage.Content.Substring(1));
       }
       else if (textMessage.Content.StartsWith("u"))
       {
     textMessage.Content = textMessage.Content.Substring(1);
       }
       else
       {
     LoggerFacade.Log("DeflateResolver.GetMessageObject: missing prefix",
     Category.Exception);
       }
       return BaseResolver.GetMessageObject(textMessage);
 }
Exemple #3
0
 private void HandleGameMessage(int senderId, BinaryReader reader)
 {
   if (battleHost != null)
   {
     string header = reader.ReadString();
     string content = reader.ReadString();
     var message = new TextMessage(header, content);
     battleHost.OnReceived(senderId, message);
   }
   else if (battleClient != null && senderId == battleClient.HostId)
   {
     string header = reader.ReadString();
     string content = reader.ReadString();
     var message = new TextMessage(header, content);
     battleClient.OnReceived(message);
   }
 }