Beispiel #1
0
    /// <summary>
    /// 处理消息
    /// </summary>
    private void MsgUpdate()
    {
        if (clientSocket.msgCount == 0)
        {
            // 没有要处理的消息
            return;
        }

        // 处理消息
        for (int i = 0; i < MAX_MESSAGE_FIRE; i++)
        {
            MsgBase msg = null;
            lock (clientSocket.msgList)
            {
                if (clientSocket.msgList.Count > 0)
                {
                    msg = clientSocket.msgList[0];
                    clientSocket.msgList.RemoveAt(0);
                    clientSocket.msgCount--;
                }
            }
            // 消息分发
            if (msg != null)
            {
                Dispatcher.HandlerEvent(msg.GetCommand(), msg);
            }
            else
            {
                break;
            }
        }
    }
Beispiel #2
0
    void OnLoginMsgResponse(MsgBase msg)
    {
        LoginReqMsg loginMsg = (LoginReqMsg)msg;

        Debug.Log(msg.GetCommand().ToString() + "/" + loginMsg.id + "/" + loginMsg.pwd);
    }