Exemplo n.º 1
0
        private void OnChat_FriendChatsRes(Datagram datagram)
        {
            FriendChatsRes res = datagram.UnSerialData <FriendChatsRes>();

            if (RunningDatas.RequestTable.TryGetValue(datagram.RequestID, out RequestSender value))
            {
                value.RequestCallback(res);
            }
        }
Exemplo n.º 2
0
        private void OnFriendChatsReq(Datagram datagram)
        {
            FriendChatsReq req = datagram.UnSerialData <FriendChatsReq>();

            FriendChatsRes res = new FriendChatsRes();

            ChatPackage[] chats = UserChatReader.ReadFriendChat(req.Sender, req.Friend, datagram.RequestID);

            byte[][] buffer;
            if (null != chats)
            {
                for (int i = 0; i < chats.Length; ++i)
                {
                    res.Chat.Add(chats[i] as FriendChatPackage);
                }

                buffer = res.ToByteArrays();
            }
            else
            {
                buffer = new byte[1][]
                {
                    new byte[0]
                }
            };

            datagram.DataType    = DatagramType.Client;
            datagram.MessageType = ChatDatagramDefine.FriendChatsRes;
            for (int i = 0; i < buffer.Length; ++i)
            {
                datagram.Datas = buffer[i];
                if (!Send(datagram.ToByteArray()))
                {
                    Notify(IKXTServer.LogLevel.Error, "数据发送异常");
                    Close();
                }
            }
        }