Exemplo n.º 1
0
        public void OnUpdate(float elapse)
        {
            SocketConnectState tmp = null;

            while (socketStateQueue.TryDequeue(out tmp))
            {
                Debug.LogFormat("SocketConnectState state = {0} error = {1}", tmp.socketState, tmp.errorno);
                this.Context.CoreModules.eventMDL.Publish(DefineEvent.EVENT_SOCKET_STATUS, tmp);
            }

            IReceiver receiver = null;

            while (receiverQueue.TryDequeue(out receiver))
            {
                //Debug.LogFormat("receiverQueue TryDequeue receiver ID = {0}", receiver.ID);
                receiver.Process();
                ReceiverHelper.RecycleReceiver(receiver);
            }

            IBaseMessage msg = null;

            while (senderQueue.TryDequeue(out msg))
            {
                Context.msgSender.SendMsg(msg);
                ReceiverHelper.RecycleMessage(msg);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 接收消息池处理方法,每帧调用一次
 /// </summary>
 private void ReciveMsgHandler()
 {
     while (!ReciveMsgPool.IsEmpty)
     {
         ReciveMsgVO msg = null;
         ReciveMsgPool.TryDequeue(out msg);
         if (msg == null)
         {
             continue;
         }
         MsgNoS2C msgNo = (MsgNoS2C)msg.channel;
         ClientAIMgr.Instance.ShowMsgLog(string.Format("消息:{0} 消息号:{1}", msgNo.ToString(), msg.channel));
         if (msgHandleDic.ContainsKey(msgNo))
         {
             for (int i = 0; i < msgHandleDic[msgNo].Count; i++)
             {
                 try
                 {
                     msgHandleDic[msgNo][i](msg.bytes);
                 }
                 catch (System.Exception e)
                 {
                     Debug.LogError(string.Format("{0} {1}", e.Message, e.StackTrace));
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
        public static IReceiver PopReceiver()
        {
            IReceiver receiver = null;

            while (!receiverPool.TryDequeue(out receiver))
            {
                return(CreateInstance <BaseReceiver>());
            }
            return(receiver);
        }
Exemplo n.º 4
0
        public static IBaseMessage PopMessage()
        {
            IBaseMessage msg = null;

            while (!msgPool.TryDequeue(out msg))
            {
                return(CreateInstance <BaseMessage>());
            }
            return(msg);
        }
Exemplo n.º 5
0
    /// <summary>
    /// 主线程 数据转发
    /// </summary>
    public void OnUpdate()
    {
        int errorCode;

        while (errors.TryDequeue(out errorCode))
        {
            //可以从这里广播出去
            UnityEngine.Debug.LogError("Tcp发生错误 :" + errorCode);
        }

        SyncHandleTcpMessage();
    }
Exemplo n.º 6
0
 /// <summary>
 /// 发送消息池处理
 /// </summary>
 private void SendMsgHandler()
 {
     while (!SendMsgPool.IsEmpty)
     {
         SendMsgVO sendMsgVO = null;
         SendMsgPool.TryDequeue(out sendMsgVO);
         if (sendMsgVO == null)
         {
             continue;
         }
         if (GlobalData.LoginServer == "127.0.0.1")
         {
             ClientAIMgr.Instance.SendBuff(sendMsgVO.channel, sendMsgVO.msgType, sendMsgVO.tbuff);
         }
         else
         {
             if (NetMgr.Instance.ConnentionDic.ContainsKey(sendMsgVO.socketType))
             {
                 NetMgr.Instance.ConnentionDic[sendMsgVO.socketType].SendBuff(sendMsgVO.channel, sendMsgVO.msgType, sendMsgVO.tbuff, sendMsgVO.offCheckTimeOut);
             }
         }
         ClientAIMgr.Instance.ShowSendMsgLog((MsgNoC2S)sendMsgVO.channel, sendMsgVO.tbuff);
     }
 }