Ejemplo n.º 1
0
        /// <summary>
        /// 处理由gate转发的client消息
        /// </summary>
        /// <param name="packet"></param>
        private void HandleProxyClientMsg(PacketBase packet)
        {
            ProxyC2SMsg proxy_msg = packet as ProxyC2SMsg;

            //转发的消息id
            ushort header = proxy_msg.data.ReadUShort();

            if (header < ProtocolID.MSG_BASE_C2SS || header >= ProtocolID.MSG_BASE_C2SS + ProtocolID.MSG_APPLAYER_PER_INTERVAL)
            {
                Log.Debug("收到错误的消息ID:" + header);
                return;
            }

            PacketBase msg = PacketPools.Get(header);

            msg.Read(proxy_msg.data);

            //处理
            ushort          msg_id = (ushort)(header - ProtocolID.MSG_BASE_C2SS);
            MsgProcFunction fun    = m_client_msg_proc[msg_id];

            if (fun == null)
            {
                Log.Debug("未注册消息处理函数ID:" + header);
            }
            else
            {
                fun(msg);
            }
            PacketPools.Recover(msg);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 处理由gate转发到fs的消息
        /// </summary>
        private void HandleProxyMsgToFS(ClientSession session, ushort header, ByteArray data)
        {
            if (session.fs_uid == 0)
            {
                Log.Debug("已经与fs断开连接");
                return;
            }
            if (session.session_status != eSessionStatus.IN_GAMING && session.session_status != eSessionStatus.ALREADY_LOGIN)
            {
                Log.Debug("session状态错误:" + session.session_status);
                return;
            }
            ProxyC2SMsg msg = PacketPools.Get(gs2fs.msg.PROXY_CLIENT_MSG) as ProxyC2SMsg;

            msg.Set(session.client_uid, header, data);
            ForServerNetManager.Instance.Send(session.fs_uid, msg);
        }