示例#1
0
 /// <summary>从缓冲区中读取一个FriendLevel结构
 /// </summary>
 /// <param name="buf">The buf.</param>
 public void Read(ByteBuffer buf)
 {
     QQ = buf.GetUInt();
     ActiveDays = buf.GetUInt();
     Level = buf.GetUShort();
     UpgradeDays = buf.GetUShort();
 }
示例#2
0
        public void Read( ByteBuffer buf)
        {
            while (buf.HasRemaining())
               {
               byte type = buf.Get();
               int len = buf.GetUShort();
               switch (type)
               {
                   case 0x01:
                       FaceId = buf.Get();
                       break;
                   case 0xff:
                       FFData = buf.GetByteArray(len);
                       break;
                   default:
                       QQClient.LogManager.Log(base.ToString()+" Parse Error,Unknown Type=" + type.ToString("X") + ": Data=" + Utils.Util.ToHex(buf.GetByteArray(len)));
                       break;

               }
               }
               if (buf.HasRemaining())
               {
               RemainBytes = buf.GetByteArray(buf.Remaining());
               QQClient.LogManager.Log(base.ToString() + " Class Parse Buf Remaining Data:" + Utils.Util.ToHex(RemainBytes));
               }
        }
示例#3
0
 public void Read(ByteBuffer buf)
 {
     buf.Get();//0x01
        int len=buf.GetUShort();
        Text = Utils.Util.GetString(buf.GetByteArray(len));
        if (buf.HasRemaining())
        {
        RemainBytes = buf.GetByteArray(buf.Remaining());
        QQClient.LogManager.Log("NormalIMText Class Parse Buf Remaining Data:" + Utils.Util.ToHex(RemainBytes));
        }
 }
示例#4
0
        /// <summary>给定一个输入流,解析SMS结构
        /// </summary>
        /// <param name="buf">The buf.</param>
        public void ReadBindUserSMS(ByteBuffer buf)
        {
            // 未知1字节,0x0
            buf.Get();
            // 发送者QQ号,4字节
            Sender = buf.GetInt();
            // 发送者头像
            Header = (int)buf.GetUShort();
            // 发送者名称,最多13字节,不足后面补0
            SenderName = Utils.Util.GetString(buf, (byte)0, QQGlobal.QQ_MAX_SMS_SENDER_NAME);
            // 未知的1字节,0x4D
            buf.Get();
            // 消息内容
            Message = Utils.Util.GetString(buf, (byte)0);

            Time = DateTime.Now.Millisecond;
        }
示例#5
0
        public string AnalyseMessage09(byte[] buffer)
        {
            ByteBuffer buf = new ByteBuffer(buffer);
            string Msg = "";
            while (buf.HasRemaining())
            {
                byte type = buf.Get();
                int len = buf.GetUShort();
                switch (type)
                {
                    case 0x01://pure text
                        //len_str = buf.GetUShort();
                        Msg += new NormalIMText(QQClient, buf.GetByteArray(len)).ToString();
                        break;
                    case 0x02://face
                        Msg += new NormalIMFace(QQClient, buf.GetByteArray(len)).ToString();
                        break;
                    case 0x06://image
                        Msg += new NormalIMImage(QQClient, buf.GetByteArray(len)).ToString();
                        break;
                    default:
                        QQClient.LogManager.Log(ToString() + " Class Parse Unknown Type=0x" + type.ToString("X") + " Data=" + Utils.Util.ToHex(buf.GetByteArray(len)));
                        break;

                }

            }
            return Msg;
        }
示例#6
0
 /// <summary>
 /// </summary>
 /// <param name="buf">The buf.</param>
 public void Read(ByteBuffer buf)
 {
     // 发送者
     Sender = buf.GetInt();
     // 未知的4字节
     buf.GetInt();
     // 昵称
     int len = buf.Get() & 0xFF;
     Nick = Utils.Util.GetString(buf, len);
     // 群名称
     len = buf.Get() & 0xFF;
     Site = Utils.Util.GetString(buf, len);
     // 未知的1字节
     buf.Get();
     // 时间
     Time = (long)buf.GetInt() * 1000L;
     // 后面的内容长度
     len = buf.GetUShort();
     // 得到字体属性长度,然后得到消息内容
     int fontStyleLength = buf.Get(buf.Position + len - 1) & 0xFF;
     Message = Utils.Util.GetString(buf, len - fontStyleLength);
     // 字体属性
     FontStyle = new FontStyle();
     FontStyle.Read(buf);
 }
示例#7
0
 /// <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);
     }
 }
示例#8
0
 protected override void ParseHeader(ByteBuffer buf)
 {
     if (!user.IsUdp) buf.GetChar();
     Header = buf.Get();
     Source = buf.GetChar();
     Command = (QQCommand)buf.GetUShort();
     Sequence = buf.GetChar();
     qqNum = buf.GetUInt();
 }
示例#9
0
 /// <summary>
 /// 给定一个输入流,解析FileTransferArgs结构
 /// </summary>
 /// <param name="buf">The buf.</param>
 public void Read(ByteBuffer buf)
 {
     // 跳过19个无用字节
     buf.Position = buf.Position + 19;
     // 读取传输类型
     TransferType = (TransferType)buf.Get();
     // 读取连接方式
     ConnectMode = (FileConnectMode)buf.Get();
     // 读取发送者外部ip
     InternetIP = buf.GetByteArray(4);
     // 读取发送者外部端口
     InternetPort = (int)buf.GetUShort();
     // 读取文件传送端口
     if (ConnectMode != FileConnectMode.DIRECT_TCP)
         MajorPort = (int)buf.GetUShort();
     else
         MajorPort = InternetPort;
     // 读取发送者真实ip
     LocalIP = buf.GetByteArray(4);
     // 读取发送者真实端口
     MinorPort = (int)buf.GetUShort();
 }
示例#10
0
        /// <summary>
        /// 解析包体,从buf的开头位置解析起
        /// <remark>abu 2008-02-18 </remark>
        /// </summary>
        /// <param name="buf">The buf.</param>
        protected override void ParseBody(ByteBuffer buf)
        {
            #if DEBUG
            Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray()));
            #endif
            Empty = false;
            // 检查消息长度,至少要有16字节,因为我们需要前16字节做为确认发回
            if (buf.Remaining() < 16)
            {
                throw new PacketParseException("收到的消息太短,抛弃该消息");
            }
            // 得到前16个字节用作回复
            Reply = buf.GetByteArray(16);
            // 读取消息头
            buf.Position = 0;
            Header = new ReceiveIMHeader();
            Header.Read(buf);
            // 检查输入流可用字节
            if (!buf.HasRemaining())
            {
                Empty = true;
                return;
            }
            // 判断消息类型
            int len = 0;
            switch (Header.Type)
            {
                case RecvSource.FRIEND_0801: //手机消息
                    buf.Position += 10;//buf.GetInt();
                    ParseNormalIM(buf);
                    break;
                case RecvSource.FRIEND_0802:
                    ParseNormalIM(buf);
                    break;
                case RecvSource.FRIEND_09:
                    buf.Position += 11;
                    ParseNormalIM(buf);
                    break;
                case RecvSource.FRIEND_09SP1:
                    buf.Position += 2;
                    int len1 = buf.GetUShort();
                    buf.Position += len1;
                    ParseNormalIM(buf);
                    break;
                case RecvSource.STRANGER:
                    /* 是从好友或者陌生人处发来的消息 */
                    ParseNormalIM(buf);
                    break;

                case RecvSource.TEMP_SESSION:
                    TempSessionIM = new TempSessionIM();
                    TempSessionIM.Read(buf);
                    break;
                case RecvSource.SYS_MESSAGE:
                    /* 是系统消息 */
                    buf.GetInt();//00 00 00 00
                    ParseSystemMessage(buf);
                    break;
                case RecvSource.CLUSTER_09:
                    /* 群消息09 */
                    ParseClusterIM09(buf);
                    break;
                case RecvSource.CLUSTER:

                    /* 群消息 */
                    ParseClusterIM(buf);
                    break;
                case RecvSource.TEMP_CLUSTER:
                    /* 临时群消息 */
                    ParseTempClusterIM(buf);
                    break;
                case RecvSource.UNKNOWN_CLUSTER:
                    ParseUnknownClusterIM(buf);
                    break;
                case RecvSource.BIND_USER:
                    SMS = new SMS();
                    SMS.ReadBindUserSMS(buf);
                    break;
                case RecvSource.MOBILE_QQ:
                    SMS = new SMS();
                    SMS.ReadMobileQQSMS(buf);
                    break;
                case RecvSource.MOBILE_QQ_2 :
                    SMS = new SMS();
                    SMS.ReadMobileQQ2SMS(buf);
                    break;
                case RecvSource.MOBILE:
                    SMS = new SMS();
                    SMS.ReadMobileSMS(buf);
                    break;
                case RecvSource.CREATE_CLUSTER:
                case RecvSource.ADDED_TO_CLUSTER:
                case RecvSource.DELETED_FROM_CLUSTER:
                    ExternalId = buf.GetInt();
                    ClusterType = (ClusterType)buf.Get();
                    Sender = buf.GetInt();
                    break;
                case RecvSource.APPROVE_JOIN_CLUSTER:
                case RecvSource.REJECT_JOIN_CLUSTER:
                case RecvSource.REQUEST_JOIN_CLUSTER:
                    ExternalId = buf.GetInt();
                    ClusterType = (ClusterType)buf.Get();
                    Sender = buf.GetInt();
                    len = buf.Get() & 0xFF;
                    byte[] b = buf.GetByteArray(len);
                    Message = Utils.Util.GetString(b);
                    break;
                case RecvSource.CLUSTER_NOTIFICATION:
                    ExternalId = buf.GetInt();
                    ClusterType = (ClusterType)buf.Get();
                    OpCode = buf.Get();
                    MemberQQ = buf.GetInt();
                    Role = buf.Get();
                    Sender = ExternalId;
                    break;
                case RecvSource.SIGNATURE_CHANGE:
                    SignatureOwner = buf.GetInt();
                    ModifiedTime = buf.GetInt();
                    len = buf.Get() & 0xFF;
                    Signature = Utils.Util.GetString(buf, len);
                    break;
                case RecvSource.QQLIVE:
                    QQLive = new QQLive();
                    QQLive.Read(buf);
                    break;
                case RecvSource.MEMBER_LOGIN_HINT:
                    buf.Get();
                    break;
                case RecvSource.CUSTOM_HEAD_CHANGE:
                    int count = buf.Get() & 0xFF;
                    if (count > 0)
                    {
                        HeadChanges = new List<CustomHead>();
                        while (buf.HasRemaining())
                        {
                            CustomHead change = new CustomHead();
                            change.Read(buf);
                            HeadChanges.Add(change);
                        }
                    }
                    break;
                case RecvSource.PROPERTY_CHANGE :
                    PropertyChange = new UserPropertyChange();
                    PropertyChange.Read(buf);
                    break;
                case RecvSource.INPUT_STATE_CHANGE: //输入状态
                    buf.GetInt();//00 00 00 00
                    Sender = buf.GetInt();//09 58 8C 87
                    buf.Get();//00
                    break;
                default:
                    // 其他类型的消息我们现在没有办法处理,忽略
                    Client.LogManager.Log(ToString() + " Unknown RecvSource=0x" + Header.Type.ToString("X"));
                    break;
            }
        }
        protected override void ParseBody(ByteBuffer buf)
        {
            #if DEBUG
            Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray()));
            #endif
            buf.Position += 10;
            // 当前好友列表位置
            Position = buf.GetUShort();
            Finished = Position == 0xFFFF;
            buf.Position += 5;
            // 只要还有数据就继续读取下一个friend结构
            Friends = new List<QQFriend>();
            while (buf.Position+5<buf.Length)
            {
                int qq = buf.GetInt();
                QQFriend friend=Client.QQUser.Friends.Get(qq);
                if(friend==null)
                    friend=Client.QQUser.Friends.Add(qq);
                    friend.Read(buf);
                    Friends.Add(friend);

            }
        }
示例#12
0
        /// <summary>
        ///  给定一个输入流,解析FriendStatus结构
        /// </summary>
        /// <param name="buf">The buf.</param>
        public void Read(ByteBuffer buf)
        {
            // 000-003: 好友QQ号
            QQ = buf.GetInt();
            // 004: 0x01,未知含义
            Unknown1 = buf.Get();
            // 005-008: 好友IP
            IP = buf.GetByteArray(4);
            // 009-010: 好友端口
            Port = buf.GetUShort();
            // 011: 0x01,未知含义
            Unknown2 = buf.Get();
            // 012: 好友状态
            Status = (QQStatus)buf.Get();
            // 013-014: 未知含义
            Version = buf.GetChar();
            // 015-030: key,未知含义
            UnknownKey = buf.GetByteArray(QQGlobal.QQ_LENGTH_KEY);

            UserFlag = buf.GetUInt();
            // 2个未知字节
            Unknown3 = buf.GetUShort();
            // 1个未知字节
            Unknown4 = buf.Get();
            buf.GetInt();
        }
示例#13
0
 /// <summary>
 /// 给定一个输入流,解析QQFriend结构
 /// </summary>
 /// <param name="buf">The buf.</param>
 public void Read(ByteBuffer buf)
 {
     //// 000-003: 好友QQ号
     //QQ = buf.GetInt();
     // 004-005: 头像
     Header = buf.GetUShort();
     // 006: 年龄
     Age = buf.Get();
     // 007: 性别
     Gender = (Gender)buf.Get();
     // 008: 昵称长度
     int len = (int)buf.Get();
     byte[] b = buf.GetByteArray(len);
     Nick = Util.GetString(b);
     // 用户属性
     UserFlag = buf.GetUInt();
     buf.Position += 23;
 }
 /// <summary>
 /// 处理提交组织架构的回复包
 /// 	<remark>abu 2008-02-22 </remark>
 /// </summary>
 /// <param name="buf">The buf.</param>
 private void ParseCommitOrganization(ByteBuffer buf)
 {
     if (ReplyCode == ReplyCode.OK)
     {
         ClusterId = buf.GetUInt();
         OrganizationVersionId = buf.GetUInt();
         OrganizationCount = (uint)buf.GetUShort();
     }
 }
        ///// <summary>
        ///// QQ群列表
        ///// </summary>
        //public List<ClusterInfo> ClusterList { get; set; }
        protected override void ParseBody(ByteBuffer buf)
        {
            #if DEBUG
            Client.LogManager.Log(ToString() + " Decoded Data:" + Utils.Util.ToHex(buf.ToByteArray()));
            #endif

            ReplyCode = buf.GetChar();//00 9C
            buf.GetInt();//00 00 00 00
            NextPos = buf.GetUShort();
            Finished = !(ReplyCode == 0x038A && NextPos > 0);
            //this.ClusterList = new List<ClusterInfo>();
            //this.QQFriendList = new List<QQFriend>();
            this.QQList = new List<QQBasicInfo>();
            while (buf.Position + 2 < buf.Length)
            {
                int number = buf.GetInt();
                QQType type =(QQType) buf.Get();
                byte gid = buf.Get();

                QQBasicInfo qq = new QQBasicInfo(number, type, ((int)gid) / 4);
                //qq.UIN = number;
                //qq.GroupId = ((int)gid) / 4;
                //qq.Type = (QQType)type;
                this.QQList.Add(qq);
                //if (type == 0x04)
                //{
                //    ClusterInfo ci = new ClusterInfo();
                //    ci.ClusterId =(uint) number;//群内部号码
                //    this.ClusterList.Add(ci);
                //}
                //else if (type == 0x01)
                //{
                //    QQFriend friend = new QQFriend();

                //    friend.QQ = number;
                //    friend.GroupId = ((int)gid)/4;
                //    this.QQFriendList.Add(friend);
                //}
                //else
                //{
                //    Client.LogManager.Log("unknown type: type=0x"+type.ToString("X2")+" number="+number.ToString() +" gid=0x"+gid.ToString("X2"));
                //}

            }
        }
示例#16
0
        public void Read(ByteBuffer buf)
        {
            Time = buf.GetInt();
            int len = buf.Get() & 0xFF;
            ShortDesc = Utils.Util.GetString(buf, len);
            len = buf.Get() & 0xFF;
            Wind = Utils.Util.GetString(buf, len);
            LowTemperature = buf.GetUShort();
            HighTemperature = buf.GetUShort();
            buf.Get();
            len = buf.Get() & 0xFF;
            Hint = Utils.Util.GetString(buf, len);

            DateTime date = Utils.Util.GetDateTimeFromMillis((long)Time * 1000L);
            Year = date.Year;
            Month = date.Month;
            Day = date.Day;
        }
 protected override void ParseBody(ByteBuffer buf)
 {
     #if DEBUG
     Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray()));
     #endif
     SubCommand = buf.Get();
     buf.GetChar();//0006
     byte verify = buf.Get();
     if (verify != 0)
     {
         if (buf.Position == buf.Length)//输入的验证码不正确
         {
             //应该返回验证码不正确的消息
             IsWrongVerifyCode = true;
             Client.LogManager.Log(ToString() + " 验证码不正确!");
             return;
         }
         NeedVerify = true;//需要输入验证码
         int len = buf.GetUShort();
         Url = Utils.Util.GetString(buf.GetByteArray(len));
     //                string getQQSession = "";
     //                VerifyCodeFileName=Utils.Util.MapPath("\\verify\\" + Client.QQUser.QQ + ".jpg");
     //                Utils.Util.DownLoadFileFromUrl(url, VerifyCodeFileName, out getQQSession);
     //#if DEBUG
     //                Client.LogManager.Log(ToString() + string.Format(" url:{0}, Session:{1},Code File:{2}", url, getQQSession, VerifyCodeFileName));
     //#endif
     //                Client.QQUser.QQKey.QQSessionToken = Utils.Util.GetBytes(getQQSession);
     }
     else
     {
         int len = buf.GetUShort();
         Token = buf.GetByteArray(len);
     }
 }
 protected override void ParseBody(ByteBuffer buf)
 {
     SubCommand = (UserPropertySubCmd)buf.Get();
     switch (SubCommand)
     {
         case UserPropertySubCmd.GET:
             StartPosition = buf.GetUShort();
             Finished = StartPosition == QQGlobal.QQ_POSITION_USER_PROPERTY_END;
             int pLen = buf.Get() & 0xFF;
             Properties = new List<UserProperty>();
             while (buf.HasRemaining())
             {
                 UserProperty p = new UserProperty(pLen);
                 p.Read(buf);
                 Properties.Add(p);
             }
             break;
     }
 }
示例#19
0
 /// <summary>给定一个输入流,解析NormalIM结构
 /// </summary>
 /// <param name="buf">The buf.</param>
 public void Read(ByteBuffer buf)
 {
     FontStyle = new FontStyle();
     // 是否有字体属性
     HasFontAttribute = buf.GetInt() != 0;
     // 分片数
     TotalFragments = (int)buf.Get();
     // 分片序号
     FragmentSequence = (int)buf.Get();
     // 消息id 两个字节
     MessageId = (int)buf.GetUShort();
     // 消息类型,这里的类型表示是正常回复还是自动回复之类的信息
     ReplyType = (ReplyType)buf.Get();
     // 消息正文,长度=剩余字节数 - 包尾字体属性长度
     int remain = buf.Remaining();
     int fontAttributeLength = HasFontAttribute ? (buf.Get(buf.Position + remain - 1) & 0xFF) : 0;
     MessageBytes = buf.GetByteArray(remain - fontAttributeLength);
     // 这后面都是字体属性,这个和SendIMPacket里面的是一样的
     if (HasFontAttribute)
     {
         if (buf.HasRemaining())
             FontStyle.Read(buf);
         else
             HasFontAttribute = false;
     }
 }
示例#20
0
 /// <summary>
 /// 从群成员信息GetClusterMemberInfo包中读取相关信息
 /// 2010/2/22 Veonax 添加
 /// </summary>
 /// <param name="buf">The buf.</param>
 public void ReadFromCluster(ByteBuffer buf)
 {
     //// 000-003: 好友QQ号
     QQBasicInfo.QQ = buf.GetInt();
     // 004-005: 头像
     Header = buf.GetUShort();
     // 006: 年龄
     Age = buf.Get();
     // 007: 性别
     Gender = (Gender)buf.Get();
     // 008: 昵称长度
     int len = (int)buf.Get();
     byte[] b = buf.GetByteArray(len);
     Nick = Util.GetString(b, "GB2312");
     // 用户属性
     UserFlag = buf.GetUInt();
 }
示例#21
0
        /// <summary>
        /// 分析09的流
        /// </summary>
        /// <param name="buf"></param>
        public void Read09(ByteBuffer buf)
        {
            FontStyle = new FontStyle();
            // 是否有字体属性
            HasFontAttribute = buf.GetInt() != 0;
            // 分片数
            TotalFragments = (int)buf.Get();
            // 分片序号
            FragmentSequence = (int)buf.Get();
            // 消息id 两个字节
            MessageId = (int)buf.GetUShort();
            // 消息类型,这里的类型表示是正常回复还是自动回复之类的信息
            ReplyType = (ReplyType)buf.Get();
            // 消息正文
            #region 字体属性开始 未处理
            buf.Position += 8;//'M' 'S' 'G' 00 00 00 00 00
            buf.GetInt();//send time
            buf.Position += 12;//5D 69 71 DE 00 80 80 00 0A 00 86 00  参见sendim
            int len = buf.GetUShort();
            buf.GetByteArray(len);//字体 E5 AE 8B E4 BD 93 =宋体
            #endregion
            buf.GetUShort();//00 00
            IsNormalIM09 = true;//标注09的信息
            MessageBytes = buf.GetByteArray(buf.Remaining());
            //_Message = "";
            //while (buf.HasRemaining())
            //{
            //    byte type = buf.Get();
            //    len = buf.GetUShort();
            //    switch (type)
            //    {
            //        case 0x01://pure text
            //            //len_str = buf.GetUShort();
            //            _Message +=new NormalIMText(QQClient,buf.GetByteArray(len)).ToString();
            //            break;
            //        case 0x02://face
            //            _Message += new NormalIMFace(QQClient, buf.GetByteArray(len)).ToString();
            //            break;
            //        case 0x06://image
            //            _Message += new NormalIMImage(QQClient, buf.GetByteArray(len)).ToString();
            //            break;
            //        default:
            //            QQClient.LogManager.Log(ToString() + " Class Parse Unknown Type=0x" + type.ToString("X") + " Data=" + Utils.Util.ToHex(buf.GetByteArray(len)));
            //            break;

            //    }

            //}
        }
示例#22
0
 /// <summary>读取移动QQ用户的短信
 /// </summary>
 /// <param name="buf">The buf.</param>
 public void ReadMobileQQSMS(ByteBuffer buf)
 {
     // 未知1字节
     buf.Get();
     // 发送者QQ号,4字节
     Sender = buf.GetInt();
     // 发送者头像
     Header = (int)buf.GetUShort();
     // 发送者名称,最多13字节,不足后面补0
     SenderName = Utils.Util.GetString(buf, (byte)0, QQGlobal.QQ_MAX_SMS_SENDER_NAME);
     // 未知的1字节,0x4D
     buf.Get();
     // 发送时间
     Time = (long)buf.GetInt() * 1000L;
     // 未知的1字节,0x03
     buf.Get();
     // 消息内容
     Message = Utils.Util.GetString(buf, (byte)0);
 }
示例#23
0
        protected override void ParseBody(ByteBuffer buf)
        {
            SubCommand = buf.Get();
            ReplyCode = (ReplyCode)buf.Get();

            int len = buf.Get() & 0xFF;
            if (len == 0)
                return;
            Province = Utils.Util.GetString(buf, len);

            len = buf.Get() & 0xFF;
            if (len > 0)
            {
                City = Utils.Util.GetString(buf, len);
                buf.GetUShort();
                len = buf.Get() & 0xFF;
                buf.Position  = buf.Position + len;
            }
            else
            {
                buf.GetUShort();
                len = buf.Get() & 0xFF;
                City = Utils.Util.GetString(buf, len);
            }
            int count = buf.Get() & 0xFF;

            Weathers = new List<Weather>();
            while (count-- > 0)
            {
                Weather w = new Weather();
                w.Read(buf);
                Weathers.Add(w);
            }
        }
示例#24
0
        public void Read(ByteBuffer buf)
        {
            while (buf.HasRemaining())
               {
               byte type = buf.Get();
               int len = buf.GetUShort();
               switch (type)
               {
                   case 0x02:
                       FileName = Utils.Util.GetString(buf.GetByteArray(len));
                       break;
                   case 0x03://filesize
                       FileSize =(int) Utils.Util.GetUInt(buf.GetByteArray(len), 0, 4); //buf.GetInt();
                       break;
                   case 0x04://guid
                       FGuid = Utils.Util.GetString(buf.GetByteArray(len));
                       break;
                   case 0xff:
                       FFData = buf.GetByteArray(len);
                       break;
                   default:
                       QQClient.LogManager.Log(base.ToString()+" Parse Error,Unknown Type=" + type.ToString("X") + ": Data=" + Utils.Util.ToHex(buf.GetByteArray(len)));
                       break;

               }
               }
               if (buf.HasRemaining())
               {
               RemainBytes = buf.GetByteArray(buf.Remaining());
               QQClient.LogManager.Log(base.ToString() + " Class Parse Buf Remaining Data:" + Utils.Util.ToHex(RemainBytes));
               }
        }
示例#25
0
 /// <summary>
 /// 给定一个输入流,解析NormalIMHeader结构
 /// </summary>
 /// <param name="buf">The buf.</param>
 public void Read(ByteBuffer buf)
 {
     // 发送者的QQ版本
     SenderVersion = buf.GetChar();
     // 发送者的QQ号
     Sender = buf.GetInt();
     // 接受者的QQ号
     Receiver = buf.GetInt();
     // md5处理的发送方的uid和session key,用来在传送文件时加密一些消息
     FileSessionKey = buf.GetByteArray(16);
     // 普通消息类型,比如是文本消息还是其他什么消息
     Type = (NormalIMType)buf.GetUShort();
     // 消息序号
     Sequence = buf.GetChar();
     // 发送时间
     SendTime = (long)buf.GetUInt() * 1000L;
     // 发送者头像
     SenderHeader = buf.GetChar();
 }
示例#26
0
 /// <summary>读取回复信息,接受者类型是手机号码
 /// </summary>
 /// <param name="buf">The buf.</param>
 public void ReadMobile(ByteBuffer buf)
 {
     IsQQ = false;
     Mobile = Utils.Util.GetString(buf, (byte)0, QQGlobal.QQ_MAX_SMS_MOBILE_LENGTH);
     buf.GetUShort();
     ReplyCode = (ReplyCode)buf.Get();
     int len = buf.Get() & 0xFF;
     Message = Utils.Util.GetString(buf, len);
     unknown = buf.Get();
 }
示例#27
0
        protected override void ParseBody(ByteBuffer buf)
        {
            ReplyCode = (ReplyCode)buf.Get();
            switch (ReplyCode)
            {
                case ReplyCode.OK:
                    // 001-016字节是session key
                    SessionKey = buf.GetByteArray(QQGlobal.QQ_LENGTH_KEY);
                    // 017-020字节是用户QQ号
                    buf.GetUInt();
                    // 021-024字节是服务器探测到的用户IP
                    IP = buf.GetByteArray(4);
                    // 025-026字节是服务器探测到的用户端口
                    Port = buf.GetUShort();
                    // 027-030字节是服务器自己的IP
                    ServerIP = buf.GetByteArray(4);
                    // 031-032字节是服务器的端口
                    ServerPort = buf.GetUShort();
                    // 033-036字节是本次登陆时间,为什么要乘1000?因为这个时间乘以1000才对,-_-!...
                    LoginTime = (long)buf.GetUInt() * 1000L;
                    // 037-038, 未知的2字节
                    buf.GetUShort();
                    // 039-062, 认证令牌
                    AuthToken = buf.GetByteArray(24);
                    // 063-066字节是一个未知服务器1的ip
                    // 067-068字节是一个未知服务器1的端口
                    // 069-072是一个未知服务器2的ip
                    // 073-074是一个未知服务器2的端口
                    // 075-076是两个未知字节
                    // 077-078是两个未知字节
                    buf.GetByteArray(buf.Position + 16);
                    // 079-110是client key,这个key用在比如登录QQ家园之类的地方
                    ClientKey = buf.GetByteArray(32);
                    // 111-122是12个未知字节
                    buf.GetByteArray(buf.Position + 12);
                    // 123-126是上次登陆的ip
                    LastLoginIP = buf.GetByteArray(4);
                    // 127-130是上次登陆的时间
                    LastLoginTime = (long)buf.GetUInt() * 1000L;
                    // 39个未知字节
                    // do nothing
                    break;

                case ReplyCode.LOGIN_REDIRECT:
                    // 登陆重定向,可能是为了负载平衡
                    // 001-004字节是用户QQ号
                    buf.GetUInt();
                    // 005-008字节是重定向到的服务器IP
                    RedirectIP = buf.GetByteArray(4);
                    // 009-010字节是重定向到的服务器的端口
                    RedirectPort = buf.GetUShort();
                    break;
                case ReplyCode.LOGIN_FAIL:
                    // 登录失败,我们得到服务器发回来的消息
                    byte[] b = buf.ToByteArray();
                    ReplyMessage = Utils.Util.GetString(b, 1, b.Length - 1);
                    break;
            }
        }
示例#28
0
 public int Relocate(ByteBuffer buf)
 {
     int offset = buf.Position;
     if (buf.Remaining() < 2)
         return offset;
     int len = buf.GetUShort(offset);
     if (len <= 0 || offset + len > buf.Length)
         return offset;
     else
         return offset + len;
 }
示例#29
0
 /// <summary>
 /// 给定一个输入流,解析ReceiveIMHeader结构
 /// </summary>
 /// <param name="buf">The buf.</param>
 public void Read(ByteBuffer buf)
 {
     // 发送者QQ号或者群内部ID
     Sender = buf.GetInt();
     // 接收者QQ号
     Receiver = buf.GetUInt();
     // 包序号,这个序号似乎和我们发的包里面的序号不同,至少这个是int,我们发的是char
     //     可能这个序号是服务器端生成的一个总的消息序号
     Sequence = buf.GetUInt();
     // 发送者IP,如果是服务器转发的,那么ip就是服务器ip
     SenderIP = buf.GetByteArray(4);
     // 发送者端口,如果是服务器转发的,那么就是服务器的端口 两个字节
     SenderPort = buf.GetUShort();
     // 消息类型,是好友发的,还是陌生人发的,还是系统消息等等
     Type = (RecvSource)buf.GetUShort();
 }
示例#30
0
        protected override void ParseBody(ByteBuffer buf)
        {
            #if DEBUG
            Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray()));
            #endif
            ReplyCode = buf.Get();
            buf.GetInt();
            switch (ReplyCode)
            {
                case 0x88:
                    buf.GetInt();//00000003 unknown
                    this.Level = buf.GetUShort();
                    this.ActiveDays = buf.GetUShort();
                    buf.GetChar();//unknown
                    this.UpgradeDays = buf.GetUShort();
                    Client.LogManager.Log(ToString() + " " + string.Format("level:{0} active_days:{1} upgrade_days:{2}", this.Level, this.ActiveDays, this.UpgradeDays));
                    break;
                default:
                    Client.LogManager.Log(ToString()+"unknown ReplyCode:0x"+ReplyCode.ToString("X"));
                    break;

            }
        }