Exemple #1
0
        //未完,待续

        public ClusterCommandReplyPacket(ByteBuffer buf, int length, QQUser user) : base(buf, length, user)
        {
        }
 public MessageManage(SocketService service, QQUser user, ServerMessageSubject transponder)
 {
     _service     = service;
     _user        = user;
     _transponder = transponder;
 }
        public void PacketArrived(InPacket inPacket)
        {
            // BasicInPacket packet = (BasicInPacket)inPacket;
            if (inPacket is UnknownInPacket)
            {
                client.PacketManager.OnReceivedUnknownPacket(new QQEventArgs<UnknownInPacket, OutPacket>(client, (UnknownInPacket)inPacket, null));
                return;
            }
            if (inPacket is ErrorPacket)
            {
                ErrorPacket error = (ErrorPacket)inPacket;
                if (error.ErrorType == ErrorPacketType.ERROR_TIMEOUT)
                {
                    client.PacketManager.OnSendPacketTimeOut(new QQEventArgs<InPacket, OutPacket>(client, null, error.TimeOutPacket));
                }
                else
                {
                    client.OnError(new QQEventArgs<ErrorPacket, OutPacket>(client, (ErrorPacket)inPacket, null));
                }
                return;
            }
            // 检查目前是否已经登录
            if (!client.QQUser.IsLoggedIn)
            {
                //按理说应该把在登陆之前时收到的包缓存起来,但是在实际中观察发现,登录之前收到的
                //东西基本没用,所以在这里不做任何事情,简单的抛弃这个包
                if (!IsPreloginPacket(inPacket))
                {
                    return;
                }
            }
            // 现在开始判断包的类型,作出相应的处理
            ConnectionPolicy policy = client.ConnectionManager.GetConnection(inPacket.PortName).Policy;
            // 根据输入包,检索对应的输出包
            OutPacket outPacket = policy.RetrieveSent(inPacket);
            // 这里检查是不是服务器发回的确认包
            // 为什么要检查这个呢,因为有些包是服务器主动发出的,对于这些包我们是不需要
            // 从超时发送队列中移除的,如果是服务器的确认包,那么我们就需要把超时发送队列
            // 中包移除
            switch (inPacket.Command)
            {
                //// 这三种包是服务器先发出的,我们要确认
                case QQCommand.Recv_IM:
                case QQCommand.Recv_IM_09:
                case QQCommand.BroadCast:
                case QQCommand.Friend_Change_Status:
                    break;
                // 其他情况我们删除超时队列中的包
                default:
                    client.PacketManager.RemoveResendPacket(inPacket);
                    client.PacketManager.OnSendPacketSuccessed(new QQEventArgs<InPacket, OutPacket>(client, inPacket, outPacket));
                    break;
            }
            switch (inPacket.Command)
            {
                case QQCommand.Touch:
                    client.LoginManager.ProcessLoginTouchReply((LoginTouchReplyPacket)inPacket, outPacket as LoginTouchPacket);
                    break;
                case QQCommand.LoginVerify:
                    client.LoginManager.ProcessLoginVerifyReply((LoginVerifyReplyPacket)inPacket, outPacket as LoginVerifyPacket);
                    break;
                case QQCommand.LoginGetInfo:
                    client.LoginManager.ProcessLoginGetInfoReply((LoginGetInfoReplyPacket)inPacket, outPacket as LoginGetInfoPacket);
                    break;
                case QQCommand.Login_A4:
                    client.LoginManager.ProcessLoginA4Reply((LoginA4ReplyPacket)inPacket, outPacket as LoginA4Packet);
                    break;
                case QQCommand.LoginGetList:
                    client.LoginManager.ProcessLoginGetListReply((LoginGetListReplyPacket)inPacket, outPacket as LoginGetListPacket);
                    break;
                case QQCommand.LoginSendInfo:
                    client.LoginManager.ProcessLoginSendInfoReply((LoginSendInfoReplyPacket)inPacket, outPacket as LoginSendInfoPacket);
                    break;
                case QQCommand.Keep_Alive:
                    client.LoginManager.ProcessKeepAliveReply((KeepAliveReplyPacket)inPacket, outPacket as KeepAlivePacket);
                    break;
                case QQCommand.Change_Status:
                    client.PrivateManager.ProcessChangeStatusReply((ChangeStatusReplyPacket)inPacket, outPacket as ChangeStatusPacket);
                    break;
                case QQCommand.GetLevel:
                    client.PrivateManager.ProcessGetLevelReply((GetLevelReplyPacket)inPacket, outPacket as GetLevelPacket);
                    break;
                case QQCommand.GroupLabel:
                    //client.PrivateManager.ProcessGetLevelReply((GetLevelReplyPacket)inPacket, outPacket as GetLevelPacket);
                    break;
                case QQCommand.Get_Friend_List:
                    client.FriendManager.ProcessGetFriendListReply((GetFriendListReplyPacket)inPacket, outPacket as GetFriendListPacket);
                    break;
                case QQCommand.Get_Online_OP:
                    client.FriendManager.ProcessGetFriendOnlineReply((GetOnlineOpReplyPacket)inPacket, outPacket as GetOnlineOpPacket);
                    break;
                case QQCommand.Recv_IM_09:
                case QQCommand.Recv_IM:
                    ProcessReceiveIM((ReceiveIMPacket)inPacket);
                    break;
                case QQCommand.Friend_Change_Status:
                    ProcessFriendChangeStatus((FriendChangeStatusPacket)inPacket);
                    break;
                case QQCommand.BroadCast:
                    ProcessSystemNotification((SystemNotificationPacket)inPacket);
                    break;
                case QQCommand.Add_Friend:
                    ProcessAddFriendReply((AddFriendReplyPacket)inPacket, outPacket as AddFriendPacket);
                    break;
                case QQCommand.AddFriendAuthorize:
                    ProcessAuthorizeReply((AddFriendAuthorizeReplyPacket)inPacket, outPacket as AddFriendAuthorizePacket);
                    break;
                case QQCommand.RequestToken:
                    ProcessRequestTokenReply((RequestTokenReplyPacket)inPacket, outPacket as RequestTokenPacket);
                    break;

                #region QQ2005
                case QQCommand.Request_Login_Token_05:
                    this.user = client.QQUser;
                    ProcessRequestLoginTokenReply((RequestLoginTokenReplyPacket)inPacket, outPacket as RequestLoginTokenPacket);
                    break;
                //case QQCommand.Keep_Alive_05:
                //    ProcessKeepAliveReply((KeepAliveReplyPacket)inPacket, outPacket as KeepAlivePacket);
                //    break;

                //case QQCommand.Get_Friend_List_05:
                //    ProcessGetFriendListReply((GetFriendListReplyPacket)inPacket, outPacket as GetFriendListPacket);
                //    break;

                case QQCommand.Get_UserInfo_05:
                    ProcessGetUserInfoReply((GetUserInfoReplyPacket)inPacket, outPacket as GetUserInfoPacket);
                    break;
                //case QQCommand.Change_Status_05:
                //    ProcessChangeStatusReply((ChangeStatusReplyPacket)inPacket, outPacket as ChangeStatusPacket);
                //    break;

                case QQCommand.Add_Friend_Auth_05:
                    ProcessAddFriendAuthReply((AddFriendAuthResponseReplyPacket)inPacket, outPacket as AddFriendAuthResponsePacket);
                    break;
                case QQCommand.Remove_Self_05:
                    ProcessRemoveSelfReply((RemoveSelfReplyPacket)inPacket, outPacket as RemoveSelfPacket);
                    break;
                case QQCommand.Delete_Friend_05:
                    ProcessDeleteFriendReply((DeleteFriendReplyPacket)inPacket, outPacket as DeleteFriendPacket);
                    break;

                case QQCommand.Upload_Group_Friend_05:
                    ProcessUploadGroupFriendReply((UploadGroupFriendReplyPacket)inPacket, (UploadGroupFriendPacket)outPacket);
                    break;
                case QQCommand.Modify_Info_05:
                    ProcessModifyInfoReply((ModifyInfoReplyPacket)inPacket, (ModifyInfoPacket)outPacket);
                    break;
                case QQCommand.Signature_OP_05:
                    ProcessSignatureOpReply((SignatureOpReplyPacket)inPacket, (SignatureOpPacket)outPacket);
                    break;
                case QQCommand.Privacy_Data_OP_05:
                    ProcessPrivacyDataOpReply((PrivacyDataOpReplyPacket)inPacket, (PrivacyDataOpPacket)outPacket);
                    break;
                case QQCommand.Friend_Data_OP_05:
                    ProcessFriendDataOpReply((FriendDataOpReplyPacket)inPacket, (FriendDataOpPacket)outPacket);
                    break;
                //case QQCommand.Friend_Level_OP_05:
                //    ProcessFriendLevelOpReply((FriendLevelOpReplyPacket)inPacket, (FriendLevelOpPacket)outPacket);
                //    break;
                case QQCommand.User_Property_OP_05:
                    PocessUserPropertyOpReply((UserPropertyOpReplyPacket)inPacket, (UserPropertyOpPacket)outPacket);
                    break;
                //case QQCommand.Download_Group_Friend_05:
                //    ProcessDownloadGroupFriendReply((DownloadGroupFriendReplyPacket)inPacket, (DownloadGroupFriendPacket)outPacket);
                //    break;
                case QQCommand.Group_Data_OP_05:
                    ProcessGroupNameOpReply((GroupDataOpReplyPacket)inPacket, (GroupDataOpPacket)outPacket);
                    break;
                case QQCommand.Search_User_05:
                    ProcessSearchUserReply((SearchUserReplyPacket)inPacket, (SearchUserPacket)outPacket);
                    break;
                case QQCommand.Weather_OP_05:
                    ProcessWeatherOpReply((WeatherOpReplyPacket)inPacket, (WeatherOpPacket)outPacket);
                    break;
                case QQCommand.Cluster_Cmd:
                    ProcessClusterCommandReply((ClusterCommandReplyPacket)inPacket, (ClusterCommandPacket)outPacket);
                    break;
                #endregion
                //default:

            }
        }
Exemple #4
0
 /// <summary>
 ///     改变在线状态
 /// </summary>
 public Receive_0X005C(byte[] byteBuffer, QQUser user)
     : base(byteBuffer, user, user.TXProtocol.SessionKey)
 {
 }
 /// <summary>
 ///     收到群/系统消息
 /// </summary>
 public ReceiveGroupSystemMessagesCommand(byte[] data, ISocketService service, IServerMessageSubject transponder,
     QQUser user) : base(data, service, transponder, user)
 {
     _packet = new Receive_0X0017(data, _user);
     _eventArgs = new QQEventArgs<Receive_0X0017>(_service, _user, _packet);
 }
Exemple #6
0
 public TestRoBot(ISendMessageService service, IServerMessageSubject transponder, QQUser user) : base(service, transponder, user)
 {
 }
 public ReceiveQQFriendMessagesCommand(byte[] data, SocketService service, ServerMessageSubject transponder,
                                       QQUser user) : base(data, service, transponder, user)
 {
     _packet     = new Receive_0x00CE(data, _user);
     _event_args = new QQEventArgs <Receive_0x00CE>(_service, _user, _packet);
 }
 public DownloadGroupFriendPacket(ByteBuffer buf, int length, QQUser user) : base(buf, length, user)
 {
 }
 public RemoveSelfPacket(QQUser user) : base(QQCommand.Remove_Self, true, user)
 {
 }
Exemple #10
0
 public RemoveSelfPacket(ByteBuffer buf, int length, QQUser user) : base(buf, length, user)
 {
 }
 public DefaultReceiveCommand(byte[] data, ISocketService service, IServerMessageSubject transponder, QQUser user)
     : base(data, service, transponder, user)
 {
     _packet    = new ReceiveCurrency(data, _user);
     _eventArgs = new QQEventArgs <ReceiveCurrency>(_service, _user, _packet);
 }
Exemple #12
0
        public static List <byte[]> ConstructMessage(QQUser user, Richtext message, long toQQ)
        {
            var dateTime = Util.GetTimeSeconds(DateTime.Now);
            var md5      = user.QQ_SessionKey;
            var ret      = new List <byte[]>();
            var writer   = new BinaryWriter(new MemoryStream());
            // FIXME: 使用正确的_packetCount和_packetIndex进行分段
            byte _packetCount = 1, _packetIndex = 0;

            foreach (var snippet in message.Snippets)
            {
                switch (snippet.Type)
                {
                case MessageType.Xml:
                {
                    var compressMsg = GZipByteArray.CompressBytes(snippet.Content);
                    writer.BEWrite(user.QQ);
                    writer.BEWrite(toQQ);
                    writer.Write(new byte[] { 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x00, 0x04 });
                    writer.Write(new byte[] { 0x00, 0x00, 0x00, 0x00 });
                    writer.Write(new byte[] { 0x37, 0x0F });
                    writer.BEWrite(user.QQ);
                    writer.BEWrite(toQQ);
                    writer.Write(md5);
                    writer.Write(new byte[] { 0x00, 0x0B });
                    writer.Write(Util.RandomKey(2));
                    writer.BEWrite(dateTime);
                    writer.Write(new byte[]
                        {
                            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, _packetCount, _packetIndex, 0x00, 0x00, 0x01, 0x4D,
                            0x53, 0x47,
                            0x00, 0x00, 0x00, 0x00, 0x00
                        });
                    writer.BEWrite(dateTime);
                    writer.Write(Util.RandomKey(4));
                    writer.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x86, 0x00 });
                    writer.Write(new byte[] { 0x00, 0x0C });
                    writer.Write(
                        new byte[] { 0xE5, 0xBE, 0xAE, 0xE8, 0xBD, 0xAF, 0xE9, 0x9B, 0x85, 0xE9, 0xBB, 0x91 });
                    writer.Write(new byte[] { 0x00, 0x00, 0x14 });
                    writer.BEWrite((ushort)(compressMsg.Length + 11));
                    writer.Write((byte)0x01);
                    writer.BEWrite((ushort)(compressMsg.Length + 1));
                    writer.Write((byte)0x01);
                    writer.Write(compressMsg);
                    writer.Write(new byte[] { 0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0x4D });
                    break;
                }

                case MessageType.Shake:
                {
                    writer.BEWrite(user.QQ);
                    writer.BEWrite(toQQ);
                    writer.Write(new byte[] { 0x00, 0x00, 0x00, 0x00 });
                    writer.Write(new byte[] { 0x37, 0x0F });
                    writer.BEWrite(user.QQ);
                    writer.BEWrite(toQQ);
                    writer.Write(Util.RandomKey());
                    writer.Write(new byte[] { 0x00, 0xAF });
                    writer.Write(Util.RandomKey(2));
                    writer.BEWrite(dateTime);
                    writer.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
                    writer.Write(Util.RandomKey(4));
                    writer.Write(new byte[] { 0x00, 0x00, 0x00, 0x00 });
                    break;
                }

                case MessageType.Normal:
                {
                    writer.BEWrite(user.QQ);
                    writer.BEWrite(toQQ);
                    writer.Write(new byte[]
                        {
                            0x00, 0x00, 0x00, 0x0D, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00,
                            0x01, 0x01
                        });
                    writer.Write(new byte[] { 0x36, 0x43 });
                    writer.BEWrite(user.QQ);
                    writer.BEWrite(toQQ);
                    writer.Write(md5);
                    writer.Write(new byte[] { 0x00, 0x0B });
                    writer.Write(Util.RandomKey(2));
                    writer.BEWrite(dateTime);
                    writer.Write(new byte[]
                        {
                            0x02, 0x34, 0x00, 0x00, 0x00, 0x00, _packetCount, _packetIndex, 0x00, 0x00, 0x01, 0x4D,
                            0x53, 0x47,
                            0x00, 0x00, 0x00, 0x00, 0x00
                        });
                    writer.BEWrite(dateTime);
                    writer.Write(Util.RandomKey(4));
                    writer.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x86, 0x00 });
                    writer.Write(new byte[] { 0x00, 0x06 });
                    writer.Write(new byte[] { 0xE5, 0xAE, 0x8B, 0xE4, 0xBD, 0x93 });
                    writer.Write(new byte[] { 0x00, 0x00 });
                    var messageData = Encoding.UTF8.GetBytes(snippet.Content);
                    writer.Write(new byte[] { 0x01 });
                    writer.BEWrite((ushort)(messageData.Length + 3));
                    writer.Write(new byte[] { 0x01 });
                    writer.BEWrite((ushort)messageData.Length);
                    writer.Write(messageData);
                    break;
                }

                case MessageType.Emoji:
                {
                    writer.BEWrite(user.QQ);
                    writer.BEWrite(toQQ);
                    writer.Write(new byte[]
                        {
                            0x00, 0x00, 0x00, 0x0D, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00,
                            0x01, 0x01
                        });
                    writer.Write(new byte[] { 0x36, 0x43 });
                    writer.BEWrite(user.QQ);
                    writer.BEWrite(toQQ);
                    writer.Write(md5);
                    writer.Write(new byte[] { 0x00, 0x0B });
                    writer.Write(Util.RandomKey(2));
                    writer.BEWrite(dateTime);
                    writer.Write(new byte[]
                        {
                            0x02, 0x34, 0x00, 0x00, 0x00, 0x00, _packetCount, _packetIndex, 0x00, 0x00, 0x01, 0x4D,
                            0x53, 0x47,
                            0x00, 0x00, 0x00, 0x00, 0x00
                        });
                    writer.BEWrite(dateTime);
                    writer.Write(Util.RandomKey(4));
                    writer.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x86, 0x00 });
                    writer.Write(new byte[] { 0x00, 0x06 });
                    writer.Write(new byte[] { 0xE5, 0xAE, 0x8B, 0xE4, 0xBD, 0x93 });
                    writer.Write(new byte[] { 0x00, 0x00 });
                    var faceIndex = byte.Parse(snippet.Content);
                    writer.Write(new byte[] { 0x02, 0x00, 0x14, 0x01, 0x00, 0x01 });
                    writer.Write(faceIndex);
                    writer.Write(new byte[] { 0xFF, 0x00, 0x02, 0x14 });
                    writer.Write((byte)(faceIndex + 65));
                    writer.Write(new byte[] { 0x0B, 0x00, 0x08, 0x00, 0x01, 0x00, 0x04, 0x52, 0xCC, 0x85, 0x50 });
                    break;
                }

                default:
                {
                    throw new NotImplementedException();
                }
                }

                ret.Add(writer.BaseStream.ToBytesArray());
                writer = new BinaryWriter(new MemoryStream());
            }

            return(ret);
        }
Exemple #13
0
 public static List <Send_0x00CD> SendLongMessage(QQUser User, Richtext Message, long ToQQ)
 {
     throw new NotImplementedException();
 }
        /// <summary>
        /// 处理临时会话消息
        /// </summary>
        /// <param name="pollData"></param>
        /// <returns></returns>
        private QQNotifyEvent ProcessSessionMsg(JObject pollData)
        {
            // {"retcode":0,"result":[{"poll_type":"sess_message",
            // "value":{"msg_id":25144,"from_uin":167017143,"to_uin":1070772010,"msg_id2":139233,"msg_type":140,"reply_ip":176752037,"time":1365931836,"id":2581801127,"ruin":444674479,"service_type":1,
            // "flags":{"text":1,"pic":1,"file":1,"audio":1,"video":1},"content":[["font",{"size":9,"color":"000000","style":[0,0,0],"name":"Tahoma"}],"2\u8F7D3 ",["face",1]," "]}}]}
            try
            {
                var store       = Context.Store;
                var msg         = new QQMsg();
                var fromUin     = pollData["from_uin"].ToObject <long>();
                var fromQQ      = pollData["ruin"].ToObject <long>();        // 真实QQ
                var serviceType = pollData["service_type"].ToObject <int>(); // Group:0,Discuss:1
                var typeId      = pollData["id"].ToObject <long>();          // Group ID or Discuss ID

                msg.ParseContentList(JsonConvert.SerializeObject(pollData["content"]));
                msg.Type = QQMsgType.SESSION_MSG;
                msg.To   = Context.Account;
                var ticks = pollData["time"].ToObject <long>() * 1000;
                msg.Date = ticks > DateTime.MaxValue.Ticks ? DateTime.Now : new DateTime(ticks);

                QQUser user = store.GetBuddyByUin(fromUin); // 首先看看是不是自己的好友
                if (user != null)
                {
                    msg.Type = QQMsgType.BUDDY_MSG; // 是自己的好友
                }
                else
                {
                    if (serviceType == 0)
                    { // 是群成员
                        var group = store.GetGroupByCode(typeId);
                        if (group == null)
                        {
                            group      = new QQGroup();
                            group.Code = typeId;
                            // 获取群信息
                            var groupModule = Context.GetModule <GroupModule>(QQModuleType.GROUP);
                            groupModule.GetGroupInfo(group, null);
                        }
                        foreach (var u in group.Members)
                        {
                            if (u.Uin == fromUin)
                            {
                                user = u;
                                break;
                            }
                        }
                    }
                    else if (serviceType == 1)
                    { // 是讨论组成员
                        var discuz = store.GetDiscuzByDid(typeId);
                        if (discuz == null)
                        {
                            discuz = new QQDiscuz {
                                Did = typeId
                            };

                            // 获取讨论组信息
                            var discuzModule = Context.GetModule <DiscuzModule>(QQModuleType.DISCUZ);
                            discuzModule.GetDiscuzInfo(discuz, null);
                        }

                        foreach (var u in discuz.Members)
                        {
                            if (u.Uin == fromUin)
                            {
                                user = u;
                                break;
                            }
                        }
                    }
                    else
                    {
                        user = store.GetStrangerByUin(fromUin); // 看看陌生人列表中有木有
                    }
                    if (user == null)
                    { // 还没有就新建一个陌生人,原理来说不应该这样。后面我就不知道怎么回复这消息了,但是消息是不能丢失的
                        user = new QQStranger
                        {
                            QQ       = pollData["ruin"].ToObject <long>(),
                            Uin      = fromUin,
                            Nickname = pollData["ruin"].ToString()
                        };
                        store.AddStranger((QQStranger)user);

                        // 获取用户信息
                        var userModule = Context.GetModule <UserModule>(QQModuleType.USER);
                        userModule.GetStrangerInfo(user, null);
                    }
                }
                user.QQ  = fromQQ; // 带上QQ号码
                msg.From = user;
                return(new QQNotifyEvent(QQNotifyEventType.ChatMsg, msg));
            }
            catch (Exception ex)
            {
                return(new QQNotifyEvent(QQNotifyEventType.NetError, ex));
            }
        }
 public SendInputNotifyAction(IQQContext context, QQActionListener listener, QQUser user)
     : base(context, listener)
 {
     this.user = user;
 }
 public DownloadGroupFriendPacket(QQUser user) : base(QQCommand.Download_Group_Friend, true, user)
 {
 }
Exemple #17
0
 public AuthorizePacket(ByteBuffer buf, int length, QQUser user) : base(buf, length, user)
 {
 }
 public RequestKeyReplyPacket(ByteBuffer buf, int length, QQUser user) : base(buf, length, user)
 {
 }
Exemple #19
0
 public SendIMPacket(ByteBuffer buf, int length, QQUser user) : base(buf, length, user)
 {
 }
        public void PacketArrived(QQ.NET.Packets.InPacket inPacket)
        {
            // BasicInPacket packet = (BasicInPacket)inPacket;
            if (inPacket is UnknownInPacket)
            {
                client.PacketManager.OnReceivedUnknownPacket(new QQEventArgs <UnknownInPacket, OutPacket>(client, (UnknownInPacket)inPacket, null));
                return;
            }
            if (inPacket is ErrorPacket)
            {
                ErrorPacket error = (ErrorPacket)inPacket;
                if (error.ErrorType == ErrorPacketType.ERROR_TIMEOUT)
                {
                    client.PacketManager.OnSendPacketTimeOut(new QQEventArgs <InPacket, OutPacket>(client, null, error.TimeOutPacket));
                }
                else
                {
                    client.OnError(new QQEventArgs <ErrorPacket, OutPacket>(client, (ErrorPacket)inPacket, null));
                }
                return;
            }
            // 检查目前是否已经登录
            if (user == null || !user.IsLoggedIn)
            {
                //按理说应该把在登陆之前时收到的包缓存起来,但是在实际中观察发现,登录之前收到的
                //东西基本没用,所以在这里不做任何事情,简单的抛弃这个包
                if (!IsPreloginPacket(inPacket))
                {
                    return;
                }
            }
            // 现在开始判断包的类型,作出相应的处理
            ConnectionPolicy policy = client.ConnectionManager.GetConnection(inPacket.PortName).Policy;
            // 根据输入包,检索对应的输出包
            OutPacket outPacket = policy.RetrieveSent(inPacket);

            // 这里检查是不是服务器发回的确认包
            // 为什么要检查这个呢,因为有些包是服务器主动发出的,对于这些包我们是不需要
            // 从超时发送队列中移除的,如果是服务器的确认包,那么我们就需要把超时发送队列
            // 中包移除
            switch (inPacket.Command)
            {
            // 这三种包是服务器先发出的,我们要确认
            case QQCommand.Recv_IM:
            case QQCommand.Recv_Msg_Sys:
            case QQCommand.Recv_Msg_Friend_Change_Status:
                break;

            // 其他情况我们删除超时队列中的包
            default:
                client.PacketManager.RemoveResendPacket(inPacket);
                client.PacketManager.OnSendPacketSuccessed(new QQEventArgs <InPacket, OutPacket>(client, inPacket, outPacket));
                break;
            }
            switch (inPacket.Command)
            {
            case QQCommand.Request_Login_Token:
                this.user = client.QQUser;
                ProcessRequestLoginTokenReply((RequestLoginTokenReplyPacket)inPacket, outPacket as RequestLoginTokenPacket);
                break;

            case QQCommand.Login:
                ProcessLoginReply((LoginReplyPacket)inPacket, outPacket as LoginPacket);
                break;

            case QQCommand.Keep_Alive:
                ProcessKeepAliveReply((KeepAliveReplyPacket)inPacket, outPacket as KeepAlivePacket);
                break;

            case QQCommand.Recv_IM:
                ProcessReceiveIM((ReceiveIMPacket)inPacket);
                break;

            case QQCommand.Get_Friend_List:
                ProcessGetFriendListReply((GetFriendListReplyPacket)inPacket, outPacket as GetFriendListPacket);
                break;

            case QQCommand.Get_Online_OP:
                ProcessGetFriendOnlineReply((GetOnlineOpReplyPacket)inPacket, outPacket as GetOnlineOpPacket);
                break;

            case QQCommand.Get_UserInfo:
                ProcessGetUserInfoReply((GetUserInfoReplyPacket)inPacket, outPacket as GetUserInfoPacket);
                break;

            case QQCommand.Change_Status:
                ProcessChangeStatusReply((ChangeStatusReplyPacket)inPacket, outPacket as ChangeStatusPacket);
                break;

            case QQCommand.Recv_Msg_Friend_Change_Status:
                ProcessFriendChangeStatus((FriendChangeStatusPacket)inPacket);
                break;

            case QQCommand.Recv_Msg_Sys:
                ProcessSystemNotification((SystemNotificationPacket)inPacket);
                break;

            case QQCommand.Add_Friend_Ex:
                ProcessAddFriendExReply((AddFriendExReplyPacket)inPacket, outPacket as AddFriendExPacket);
                break;

            case QQCommand.Add_Friend_Auth:
                ProcessAddFriendAuthReply((AddFriendAuthResponseReplyPacket)inPacket, outPacket as AddFriendAuthResponsePacket);
                break;

            case QQCommand.Remove_Self:
                ProcessRemoveSelfReply((RemoveSelfReplyPacket)inPacket, outPacket as RemoveSelfPacket);
                break;

            case QQCommand.Delete_Friend:
                ProcessDeleteFriendReply((DeleteFriendReplyPacket)inPacket, outPacket as DeleteFriendPacket);
                break;

            case QQCommand.Authorize:
                ProcessAuthorizeReply((AuthorizeReplyPacket)inPacket, outPacket as AuthorizePacket);
                break;

            case QQCommand.Upload_Group_Friend:
                ProcessUploadGroupFriendReply((UploadGroupFriendReplyPacket)inPacket, (UploadGroupFriendPacket)outPacket);
                break;
            }
        }
 public ModifyInfoReplyPacket(ByteBuffer buf, int length, QQUser user) : base(buf, length, user)
 {
 }
Exemple #22
0
        public CustomRobot(ISendMessageService service, IServerMessageSubject transponder, QQUser user)
        {
            _service     = service;
            _transponder = transponder;
            _user        = user;

            // 将机器人加入转发器的订阅列表中
            _transponder.AddCustomRoBot(this);
        }
Exemple #23
0
 /// <summary>
 /// 发好友消息回复包
 /// </summary>
 public Receive_0x00CD(byte[] byteBuffer, QQUser User)
     : base(byteBuffer, User, User.QQ_SessionKey)
 {
 }
 /// <summary>
 /// 得到包的命令和序号  
 /// </summary>
 /// <param name="buf">The buf.</param>
 /// <param name="user">The user.</param>
 /// <returns></returns>
 private QQCommand GetCommand(ByteBuffer buf, QQUser user)
 {
     if (!user.IsUdp)
     {
         return (QQCommand)buf.GetUShort(offset + 5);
     }
     else
     {
         return (QQCommand)buf.GetUShort(offset + 3);
     }
 }
 /// <summary>
 ///     图片处理(上传或获取)
 /// </summary>
 public PictureCommand(byte[] data, ISocketService service, IServerMessageSubject transponder, QQUser user) :
     base(data, service, transponder, user)
 {
     _packet    = new Receive_0X0388(data, _user);
     _eventArgs = new QQEventArgs <Receive_0X0388>(_service, _user, _packet);
 }