Beispiel #1
0
 void server_OnReceive(object sender, ReceiveEventArgs e)
 {
     THOK.MCP.Message message = null;
     if (null != protocol)
         message = protocol.Parse(e.Message);
     else
     {
         Logger.Error(string.Format("UDPService出错。原因:未能找到消息'{0}'的解析类", e.Message));
         message = new THOK.MCP.Message(e.Message);
     }
     if (message.Parsed)
         DispatchState(message.Command, message.Parameters);
 }
Beispiel #2
0
 private void server_OnReceive(object sender, ReceiveEventArgs e)
 {
     try
     {
         Message message = new MessageParser().Parse(e.Message);
         List<string> receivers = message.Receivers;
         for (int i = 0; i < receivers.Count; i++)
         {
             string clientName = receivers[i].ToString();
             if (clientName.ToUpper() == this.name.ToUpper())
             {
                 this.ProcessMessage(message);
             }
             else
             {
                 this.Send(clientName, message.Msg);
             }
         }
     }
     catch
     {
     }
 }