Пример #1
0
 private void RouteManager_OnSendMessageToInner(RoutePacket <T> packet)
 {
     if (packet != null)
     {
         for (int i = 0; i < packet.Destination.Length; i++)
         {
             if (this._communicators.ContainsKey(packet.Destination[i]))
             {
                 if (this._communicators[packet.Destination[i]].IsConnected)
                 {
                     if (packet.Destination[i] == "Log")
                     {
                         this._asynInvoke.Enqueue(new WorkItemCallback(this.SendMessage),
                                                  new StateObject <T>()
                         {
                             Communicator = this._communicators[packet.Destination[i]],
                             Packet       = packet
                         }, WorkItemPriority.Lowest);
                     }
                     else
                     {
                         this._asynInvoke.Enqueue(new WorkItemCallback(this.SendMessage),
                                                  new StateObject <T>()
                         {
                             Communicator = this._communicators[packet.Destination[i]],
                             Packet       = packet
                         }, WorkItemPriority.Normal);
                     }
                 }
             }
         }
     }
 }
Пример #2
0
        private object SendMessage(object obj)
        {
            StateObject <T> sobj = obj as StateObject <T>;

            if (sobj != null)
            {
                try
                {
                    RoutePacket <T> packet = sobj.Packet;
                    return(sobj.Communicator.SendMessageToClient(packet));
                }
                catch (Exception ex)
                {
                    DebugHelper.WriteLog(String.Format("发送至通信器{{{0}}}时出现异常,异常信息:{1}", sobj.Communicator.IPAddress, ex.Message));
                }
            }
            return(false);
        }