コード例 #1
0
    public void ProcessPacket(ClientSession socket, WfPacket packet)
    {
        ushort msgType   = 0;
        ushort msgLength = 0;

        packet.ReadHeader(ref msgType, ref msgLength);
        if (ServerNet.GetEnableDebug())
        {
            Debug.Log("receive:" + Convert.ToString(msgType, 16));
        }
        System.Action <ClientSession, WfPacket> packetHandler = (System.Action <ClientSession, WfPacket>)m_KCPPacketHandlers[(ushort)msgType];
        if (packetHandler == null)
        {
            Debug.Log("msg not process=" + msgType.ToString());
        }
        else
        {
            try
            {
                packetHandler(socket, packet);
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }
        }
    }
コード例 #2
0
        public static void ProcessPacket(WfPacket packet)
        {
            ushort msgType   = 0;
            ushort msgLength = 0;

            packet.ReadHeader(ref msgType, ref msgLength);
            if (NetworkManager.GetEnableDebug(NetworkProtol.Tcp))
            {
                Debug.Log("收到:" + Convert.ToString(msgType, 16));
            }
            System.Action <WfPacket> hander = null;
            if (!m_Handlers.TryGetValue(msgType, out hander))
            {
                //Debug.LogWarning("msg not find in battle, will process in hotfix" + Convert.ToString(msgType, 16));
                //PacketHandlerMgrHF_ProcessPacket.SafeInvoke((int)msgType, (int)msgLength, packet);
            }
            else
            {
                try
                {
                    hander(packet);
                }
                catch (Exception ex)
                {
                    Debug.LogException(ex);
                }
            }
        }
コード例 #3
0
    public void ProcessPacket(DP_Msg socket, WfPacket packet)
    {
        ushort msgType   = 0;
        ushort msgLength = 0;

        packet.ReadHeader(ref msgType, ref msgLength);
        if (ServerNet.GetEnableDebug())
        {
            Debug.Log("receiving:" + msgType);
        }
        System.Action <DP_Msg, WfPacket> handler = null;
        if (!m_PacketHandlers.TryGetValue(msgType, out handler))
        {
            try
            {
                handler(socket, packet);
            }
            catch (Exception ex)
            {
                Log.print(ex.Message);
            }
        }
    }