private void HandleMessages(int maxCount)
 {
     try {
         for (int i = 0; i < maxCount; ++i)
         {
             if (m_MsgQueue.Count > 0)
             {
                 NodeMessageInfo info = null;
                 m_MsgQueue.TryDequeue(out info);
                 if (null != info)
                 {
                     try {
                         NodeMessageDispatcher.HandleNodeMessage(info.Seq, info.SourceHandle, info.DestHandle, info.Data);
                         m_MsgPool.Enqueue(info);
                     } catch (Exception ex) {
                         LogSys.Log(LOG_TYPE.ERROR, "NodeMessageThread NodeMessageDispatcher.HandleNodeMessage() throw exception:{0}\n{1}", ex.Message, ex.StackTrace);
                     }
                 }
             }
             else
             {
                 break;
             }
         }
     } catch (Exception ex) {
         LogSys.Log(LOG_TYPE.ERROR, "NodeMessageThread.HandleMessages throw exception:{0}\n{1}", ex.Message, ex.StackTrace);
     }
 }
Пример #2
0
 /// <summary>
 /// 注意,node来的消息直接分发到DataProcess的线程池里进行处理,需要考虑多线程安全!
 /// </summary>
 private void InstallNodeHandlers()
 {
     NodeMessageDispatcher.Init();
     NodeMessageDispatcher.RegisterMessageHandler((int)LobbyMessageDefine.QuitRoom, typeof(GameFrameworkMessage.NodeMessageWithGuid), typeof(GameFrameworkMessage.QuitRoom), this.HandleQuitRoom);
     NodeMessageDispatcher.RegisterMessageHandler((int)LobbyMessageDefine.EnterScene, typeof(GameFrameworkMessage.NodeMessageWithGuid), null, this.HandleEnterScene);
     NodeMessageDispatcher.RegisterMessageHandler((int)LobbyMessageDefine.ChangeSceneRoom, typeof(GameFrameworkMessage.NodeMessageWithGuid), typeof(GameFrameworkMessage.ChangeSceneRoom), HandleChangeSceneRoom);
     NodeMessageDispatcher.RegisterMessageHandler((int)LobbyMessageDefine.RequestSceneRoomInfo, typeof(GameFrameworkMessage.NodeMessageWithGuid), typeof(GameFrameworkMessage.RequestSceneRoomInfo), HandleRequestSceneRoomInfo);
     NodeMessageDispatcher.RegisterMessageHandler((int)LobbyMessageDefine.RequestSceneRoomList, typeof(GameFrameworkMessage.NodeMessageWithGuid), typeof(GameFrameworkMessage.RequestSceneRoomList), HandleRequestSceneRoomList);
     //--------------------------------------------------------------------------------------
 }
Пример #3
0
 internal void TransmitToWorld(int userSvrHandle, string nodeName, NodeMessage msg)
 {
     try {
         if (!string.IsNullOrEmpty(nodeName) && null != msg)
         {
             byte[] data = NodeMessageDispatcher.BuildNodeMessage(msg);
             if (null != data)
             {
                 Msg_LBL_Message builder = new Msg_LBL_Message();
                 builder.MsgType    = Msg_LBL_Message.MsgTypeEnum.Node;
                 builder.TargetName = nodeName;
                 builder.Data       = data;
                 m_UserChannel.Send(userSvrHandle, builder);
             }
         }
     } catch (Exception ex) {
         LogSys.Log(LOG_TYPE.ERROR, "Exception:{0}\n{1}", ex.Message, ex.StackTrace);
     }
 }