Пример #1
0
    public MessageHead PopMessage()
    {
        if (mSession == null || !mSession.IsConnected())
        {
            return(null);
        }
        MemoryStream stream = mSession.PeekMsg();

        if (stream == null)
        {
            return(null);
        }

        byte[] bytes = new byte[4];
        stream.Read(bytes, 0, 4);
        uint        msgid = BitConverter.ToUInt32(bytes, 0);
        MessageHead head  = null;

        if (msgid == (uint)TCP_MSG_ID.TCP_MSG_SC_CHAT)
        {
            head = new SCChatMessage();
            head.FromStream(stream);
        }
        return(head);
    }
Пример #2
0
 private void OnChatServerMessage(MessageHead msg)
 {
     if (msg.msgid == (uint)TCP_MSG_ID.TCP_MSG_SC_CHAT)
     {
         SCChatMessage chatMsg = (SCChatMessage)msg;
         ChatEvent     evt     = new ChatEvent(ChatEvent.CHAT_SERVER_RECV_MESSAGE);
         evt.channel_type = chatMsg.channel_type;
         evt.name         = chatMsg.name;
         evt.msg          = chatMsg.msg;
         EventSystem.Instance.PushEvent(evt);
     }
 }