Beispiel #1
0
 /// <summary>创建一个基本输出包
 ///     <remark>abu 2008-02-18 </remark>
 /// </summary>
 /// <param name="header">The header.</param>
 /// <param name="command">包命令.</param>
 /// <param name="ack">包是否需要回复.</param>
 /// <param name="user">QQ用户对象.</param>
 public OutPacket(byte header, QQCommand command, bool ack, QQUser user)
     : base(header, QQGlobal.QQ_CLIENT_VERSION, command, GetNextSeq(), user)
 {
     this.ack             = ack;
     this.resendCountDown = QQGlobal.QQ_SEND_TIME_NOACK_PACKET;
     this.SendCount       = 1;
 }
Beispiel #2
0
 /// <summary>创建一个基本输出包
 /// </summary>
 /// <param name="header">The header.</param>
 /// <param name="command">包命令.</param>
 /// <param name="ack">包是否需要回复.</param>
 /// <param name="user">QQ用户对象.</param>
 public OutPacket(byte header, QQCommand command, bool ack, QQClient client)
     : base(header, QQGlobal.QQ_CLIENT_VERSION, command, GetNextSeq(), client)
 {
     this.ack = ack;
     this.resendCountDown = QQGlobal.QQ_SEND_TIME_NOACK_PACKET;
     this.SendCount = 1;
 }
Beispiel #3
0
 /// <summary>构造一个指定参数的包
 ///     <remark>abu 2008-02-18 </remark>
 /// </summary>
 /// <param name="header">包头</param>
 /// <param name="source">包源</param>
 /// <param name="command">包命令 </param>
 /// <param name="sequence">包序号 </param>
 /// <param name="user">QQ用户对象</param>
 public Packet(byte header, char source, QQCommand command, char sequence, QQUser user)
 {
     this.user         = user;
     this.Source       = source;
     this.Command      = command;
     this.Sequence     = sequence;
     this.IsDuplicated = false;
     this.Header       = header;
     this.DateTime     = DateTime.Now;
 }
Beispiel #4
0
 /// <summary>构造一个指定参数的包
 /// </summary>
 /// <param name="header">包头</param>
 /// <param name="source">包源</param>
 /// <param name="command">包命令 </param>
 /// <param name="sequence">包序号 </param>
 /// <param name="user">QQ用户对象</param>
 public Packet(byte header, char source, QQCommand command, char sequence, QQClient client)
 {
     //this.user = user;
     this.Client = client;
     this.Source = source;
     this.Command = command;
     this.Sequence = sequence;
     this.IsDuplicated = false;
     this.Header = header;
     this.DateTime = DateTime.Now;
 }
        public PacketCommand dispatch_receive_packet(QQCommand command)
        {
            var types = Assembly.GetExecutingAssembly().GetTypes();

            foreach (var type in types)
            {
                var attributes = type.GetCustomAttributes();
                if (!attributes.Any(attr => attr is ReceivePacketCommand))
                {
                    continue;
                }

                var attribute = attributes.First(attr => attr is ReceivePacketCommand) as ReceivePacketCommand;
                if (attribute.Command == command)
                {
                    var receive_packet = Activator.CreateInstance(type, new object[] { _data, _client }) as PacketCommand;
                    return(receive_packet);
                }
            }
            return(new DefaultReceiveCommand(_data, _client));
        }
Beispiel #6
0
 public ResponsePacketCommand(QQCommand command)
 {
     Command = command;
 }
Beispiel #7
0
 /// <summary>构造一个参数指定的包.
 ///     <remark>abu 2008-02-19 </remark>
 /// </summary>
 /// <param name="command">命令.</param>
 /// <param name="ack">是否需要回应.</param>
 /// <param name="user">The user.</param>
 protected BasicOutPacket(QQCommand command, bool ack, QQUser user) : base(QQGlobal.QQ_HEADER_BASIC_FAMILY, command, ack, user)
 {
 }
Beispiel #8
0
 /// <summary>
 /// 得到hash值
 /// </summary>
 /// <param name="sequence">The sequence.</param>
 /// <param name="command">The command.</param>
 /// <returns></returns>
 public static int Hash(char sequence, QQCommand command)
 {
     return (sequence << 16) | (ushort)command;
 }
Beispiel #9
0
 /// <summary>
 /// </summary>
 /// <param name="header">The header.</param>
 /// <param name="source">The source.</param>
 /// <param name="command">The command.</param>
 /// <param name="user">The user.</param>
 public InPacket(byte header, char source, QQCommand command, QQClient client)
     : base(header, source, command, (char)0, client)
 {
 }
Beispiel #10
0
 /// <summary>
 /// </summary>
 /// <param name="header">The header.</param>
 /// <param name="source">The source.</param>
 /// <param name="command">The command.</param>
 /// <param name="user">The user.</param>
 public InPacket(byte header, char source, QQCommand command, QQClient client)
     : base(header, source, command, (char)0, client)
 {
 }
Beispiel #11
0
 public UnknownInPacket(QQCommand command,QQClient client)
     : base(command, client)
 {
 }
Beispiel #12
0
 /// <summary>
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="user">The user.</param>
 public BasicInPacket(QQCommand command, QQClient client)
     : base(QQGlobal.QQ_HEADER_BASIC_FAMILY, QQGlobal.QQ_SERVER_VERSION_0100, command, client)
 {
 }
Beispiel #13
0
 /// <summary>
 ///     <remark>abu 2008-02-18 </remark>
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="user">The user.</param>
 public BasicInPacket(QQCommand command, QQUser user) : base(QQGlobal.QQ_HEADER_BASIC_FAMILY, QQGlobal.QQ_SERVER_VERSION_0100, command, user)
 {
 }
Beispiel #14
0
 /// <summary>
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="user">The user.</param>
 public BasicInPacket(QQCommand command, QQClient client) : base(QQGlobal.QQ_HEADER_BASIC_FAMILY, QQGlobal.QQ_SERVER_VERSION_0100, command, client)
 {
 }
Beispiel #15
0
 public _05InPacket(QQCommand command, QQUser user)
     : base(QQGlobal.QQ_HEADER_05_FAMILY, QQGlobal.QQ_CLIENT_VERSION, command, user)
 {
 }
 public ReceivePackageCommand(QQCommand command)
 {
     Command = command;
 }
Beispiel #17
0
 /// <summary>
 /// 	<remark>abu 2008-02-18 </remark>
 /// </summary>
 /// <param name="header">The header.</param>
 /// <param name="source">The source.</param>
 /// <param name="command">The command.</param>
 /// <param name="user">The user.</param>
 public InPacket(byte header, char source, QQCommand command, QQUser user)
     : base(header, source, command, (char)0, user)
 {
 }
Beispiel #18
0
 /// <summary>构造一个参数指定的包.
 /// </summary>
 /// <param name="command">命令.</param>
 /// <param name="ack">是否需要回应.</param>
 /// <param name="user">The user.</param>
 protected BasicOutPacket(QQCommand command, bool ack, QQClient client)
     : base(QQGlobal.QQ_HEADER_BASIC_FAMILY, command, ack, client)
 {
 }
        public InPacket ParseIncoming(ByteBuffer buf, int len, QQClient client)
        {
            try
            {
                QQCommand Command = GetCommand(buf, client.QQUser);
//#if DEBUG
//                client.LogManager.Log("Recv " + Command.ToString() + "(0x" + Command.ToString("X") + ") Packet Data:" + Utils.Util.ToHex(buf.ToByteArray()));
//#endif
                switch (Command)
                {
                case QQCommand.Touch:
                    return(new LoginTouchReplyPacket(buf, len, client));

                case QQCommand.LoginRequest:
                    return(new LoginRequestReplyPacket(buf, len, client));

                case QQCommand.LoginVerify:
                    return(new LoginVerifyReplyPacket(buf, len, client));

                case QQCommand.LoginGetInfo:
                    return(new LoginGetInfoReplyPacket(buf, len, client));

                case QQCommand.Login_A4:
                    return(new LoginA4ReplyPacket(buf, len, client));

                case QQCommand.LoginGetList:
                    return(new LoginGetListReplyPacket(buf, len, client));

                case QQCommand.LoginSendInfo:
                    return(new LoginSendInfoReplyPacket(buf, len, client));

                case QQCommand.Keep_Alive:
                    return(new KeepAliveReplyPacket(buf, len, client));

                case QQCommand.Change_Status:
                    return(new ChangeStatusReplyPacket(buf, len, client));

                case QQCommand.GetLevel:
                    return(new GetLevelReplyPacket(buf, len, client));

                case QQCommand.GroupLabel:
                    return(new DownloadGroupFriendReplyPacket(buf, len, client));

                case QQCommand.Get_Friend_List:
                    return(new GetFriendListReplyPacket(buf, len, client));

                case QQCommand.Get_Online_OP:
                    return(new GetOnlineOpReplyPacket(buf, len, client));

                case QQCommand.Send_IM:
                    return(new SendIMReplyPacket(buf, len, client));

                case QQCommand.Recv_IM:
                case QQCommand.Recv_IM_09:
                    return(new ReceiveIMPacket(buf, len, client));

                case QQCommand.Friend_Change_Status:
                    return(new FriendChangeStatusPacket(buf, len, client));

                case QQCommand.BroadCast:
                    return(new SystemNotificationPacket(buf, len, client));

                case QQCommand.Add_Friend:
                    return(new AddFriendReplyPacket(buf, len, client));

                case QQCommand.RequestToken:
                    return(new RequestTokenReplyPacket(buf, len, client));

                case QQCommand.Cluster_Cmd:
                    return(new ClusterCommandReplyPacket(buf, len, client));

                    #region 05
                case QQCommand.Modify_Info_05:
                    return(new ModifyInfoReplyPacket(buf, len, client));

                case QQCommand.Search_User_05:
                    return(new SearchUserReplyPacket(buf, len, client));

                case QQCommand.Delete_Friend_05:
                    return(new DeleteFriendReplyPacket(buf, len, client));

                case QQCommand.Remove_Self_05:
                    return(new RemoveSelfReplyPacket(buf, len, client));

                case QQCommand.Add_Friend_Auth_05:
                    return(new AddFriendAuthResponseReplyPacket(buf, len, client));

                case QQCommand.Get_UserInfo_05:
                    return(new GetUserInfoReplyPacket(buf, len, client));



                //case QQCommand.Login_05:
                //    return new LoginReplyPacket(buf, len, client);
                case QQCommand.Get_Friend_List_05:
                    return(new GetFriendListReplyPacket(buf, len, client));

                //case QQCommand.Recv_Msg_Sys_05:
                //    return new SystemNotificationPacket(buf, len, client);

                case QQCommand.Upload_Group_Friend_05:
                    return(new UploadGroupFriendReplyPacket(buf, len, client));

                //case QQCommand.Download_Group_Friend_05:
                //    return new DownloadGroupFriendReplyPacket(buf, len, client);
                case QQCommand.Group_Data_OP_05:
                    return(new GroupDataOpReplyPacket(buf, len, client));

                case QQCommand.Friend_Data_OP_05:
                    return(new FriendDataOpReplyPacket(buf, len, client));

                case QQCommand.Request_Key_05:
                    return(new RequestKeyReplyPacket(buf, len, client));

                case QQCommand.Advanced_Search_05:
                    return(new AdvancedSearchUserReplyPacket(buf, len, client));

                case QQCommand.Cluster_Data_OP_05:
                    return(new GetTempClusterOnlineMemberReplyPacket(buf, len, client));

                case QQCommand.AddFriendAuthorize:
                    return(new AddFriendAuthorizeReplyPacket(buf, len, client));

                case QQCommand.Signature_OP_05:
                    return(new SignatureOpReplyPacket(buf, len, client));

                case QQCommand.Weather_OP_05:
                    return(new WeatherOpReplyPacket(buf, len, client));

                case QQCommand.User_Property_OP_05:
                    return(new UserPropertyOpReplyPacket(buf, len, client));

                //case QQCommand.Friend_Level_OP_05:
                //    return new FriendLevelOpReplyPacket(buf, len, client);
                case QQCommand.Send_SMS_05:
                    return(new SendSMSReplyPacket(buf, len, client));

                case QQCommand.Temp_Session_OP_05:
                    return(new TempSessionOpReplyPacket(buf, len, client));

                case QQCommand.Privacy_Data_OP_05:
                    return(new PrivacyDataOpReplyPacket(buf, len, client));

                    #endregion
                default:
                    client.LogManager.Log("Recieved an unknown Packet!");
                    return(new UnknownInPacket(buf, len, client));
                }
            }
            catch (Exception e)
            {
                client.LogManager.Log(e.Message + "\r\n" + e.StackTrace);
                return(new ErrorPacket(ErrorPacketType.RUNTIME_ERROR, client, e));
            }
            //// 如果解析失败,返回null
            //buf.Position = offset;
            //return new UnknownInPacket(buf, len, client);
        }
Beispiel #20
0
 /// <summary>
 ///     得到hash值
 /// </summary>
 /// <param name="sequence">The sequence.</param>
 /// <param name="command">The command.</param>
 /// <returns></returns>
 public static int Hash(char sequence, QQCommand command)
 {
     return((sequence << 16) | (ushort)command);
 }
Beispiel #21
0
 public UnknownInPacket(QQCommand command, QQUser user) : base(command, user)
 {
 }
Beispiel #22
0
 /// <summary>构造一个参数指定的包.
 /// </summary>
 /// <param name="command">命令.</param>
 /// <param name="ack">是否需要回应.</param>
 /// <param name="user">The user.</param>
 protected BasicOutPacket(QQCommand command, bool ack, QQClient client) : base(QQGlobal.QQ_HEADER_BASIC_FAMILY, command, ack, client)
 {
 }
Beispiel #23
0
 public UnknownInPacket(QQCommand command, QQClient client) : base(command, client)
 {
 }