예제 #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)
 {
     Id = (uint)buf.Get();
     Path = buf.GetUInt();
     int len = (int)buf.Get();
     Name = Utils.Util.GetString(buf.GetByteArray(len));
 }
예제 #3
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();
 }
 protected override void ParseBody(ByteBuffer buf)
 {
     buf.Get();
     ReplyCode = (ReplyCode)buf.Get();
     buf.Get();
     Onlines = new List<uint>();
     while (buf.HasRemaining())
         Onlines.Add(buf.GetUInt());
 }
 /// <summary>
 /// 处理得到单个成员群名片回复包
 /// 	<remark>abu 2008-02-22 </remark>
 /// </summary>
 /// <param name="buf">The buf.</param>
 private void ParseGetCard(ByteBuffer buf)
 {
     if (ReplyCode == ReplyCode.OK)
     {
         ClusterId = buf.GetUInt();
         MemberQQ = buf.GetUInt();
         Card = new Card();
         Card.Read(buf);
     }
 }
 /// <summary>
 /// 处理修改群信息的回复包
 /// 	<remark>abu 2008-02-22 </remark>
 /// </summary>
 /// <param name="buf">The buf.</param>
 private void ParseModifyInfoReply(ByteBuffer buf)
 {
     if (ReplyCode == ReplyCode.OK)
     {
         ClusterId = buf.GetUInt();
     }
 }
 /// <summary>
 /// 	<remark>abu 2008-02-22 </remark>
 /// </summary>
 /// <param name="buf">The buf.</param>
 private void ParseExitTempClusterReply(ByteBuffer buf)
 {
     if (ReplyCode == ReplyCode.OK)
     {
         Type = (ClusterType)buf.Get();
         ParentClusterId = buf.GetUInt();
         ClusterId = buf.GetUInt();
     }
 }
예제 #8
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();
 }
예제 #9
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;
            }
        }
예제 #10
0
 public void ReadTemp(ByteBuffer buf)
 {
     QQ = buf.GetUInt();
     Organization = buf.Get();
     Role = 0;
 }
예제 #11
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;
 }
 protected override void ParseBody(ByteBuffer buf)
 {
     // 得到群操作命令和回复码
     SubCommand = (ClusterCommand)buf.Get();
     ReplyCode = (ReplyCode)buf.Get();
     // 判断命令类型
     switch (SubCommand)
     {
         case ClusterCommand.SEND_IM_EX09:
         case ClusterCommand.SEND_IM_EX:
             ParseSendIMReply(buf);
             break;
         case ClusterCommand.SEND_TEMP_IM:
             ParseSendTempClusterIMReply(buf);
             break;
         case ClusterCommand.CREATE_CLUSTER:
             ParseCreateReply(buf);
             break;
         case ClusterCommand.CREATE_TEMP:
             ParseCreateTempCluster(buf);
             break;
         case ClusterCommand.ACTIVATE_CLUSTER:
             ParseActivateReply(buf);
             break;
         case ClusterCommand.MODIFY_MEMBER:
             ParseModifyMemberReply(buf);
             break;
         case ClusterCommand.GET_CLUSTER_INFO:
             ParseGetInfoReply(buf);
             break;
         case ClusterCommand.EXIT_CLUSTER:
             ParseExitReply(buf);
             break;
         case ClusterCommand.GET_MEMBER_INFO:
             ParseGetMemberInfoReply(buf);
             break;
         case ClusterCommand.GET_ONLINE_MEMBER:
             ParseGetOnlineMemberReply(buf);
             break;
         case ClusterCommand.JOIN_CLUSTER:
             ParseJoinReply(buf);
             break;
         case ClusterCommand.JOIN_CLUSTER_AUTH:
             ParseJoinAuthReply(buf);
             break;
         case ClusterCommand.MODIFY_CLUSTER_INFO:
             ParseModifyInfoReply(buf);
             break;
         case ClusterCommand.SEARCH_CLUSTER:
             ParseSearchReply(buf);
             break;
         case ClusterCommand.GET_TEMP_INFO:
             ParseGetTempClusterInfoReply(buf);
             break;
         case ClusterCommand.EXIT_TEMP:
             ParseExitTempClusterReply(buf);
             break;
         case ClusterCommand.ACTIVATE_TEMP:
             ParseActivateTempCluster(buf);
             break;
         case ClusterCommand.SUB_CLUSTER_OP:
             ParseSubClusterOp(buf);
             break;
         case ClusterCommand.UPDATE_ORGANIZATION:
             ParseUpdateOrganization(buf);
             break;
         case ClusterCommand.COMMIT_ORGANIZATION:
             ParseCommitOrganization(buf);
             break;
         case ClusterCommand.COMMIT_MEMBER_ORGANIZATION:
             ParseCommitMemberOrganization(buf);
             break;
         case ClusterCommand.MODIFY_TEMP_INFO:
             ParseModifyTempClusterInfo(buf);
             break;
         case ClusterCommand.MODIFY_CARD:
             ParseModifyCard(buf);
             break;
         case ClusterCommand.GET_CARD_BATCH:
             ParseGetCardBatch(buf);
             break;
         case ClusterCommand.GET_CARD:
             ParseGetCard(buf);
             break;
         case ClusterCommand.SET_ROLE:
             ParseSetRole(buf);
             break;
         case ClusterCommand.TRANSFER_ROLE:
             ParseTransferRole(buf);
             break;
         case ClusterCommand.DISMISS_CLUSTER:
             ParseDismissCluster(buf);
             break;
     }
     // 如果操作失败
     if (ReplyCode != ReplyCode.OK)
     {
         switch (SubCommand)
         {
             case ClusterCommand.TRANSFER_ROLE:
                 ClusterId = buf.GetUInt();
                 MemberQQ = buf.GetUInt();
                 ErrorMessage = Util.GetString(buf);
                 break;
             case ClusterCommand.SET_ROLE:
                 ClusterId = buf.GetUInt();
                 ErrorMessage = Util.GetString(buf);
                 break;
             default:
                 /* 操作失败 */
                 ErrorMessage = Util.GetString(buf);
                 break;
         }
     }
 }
 /// <summary>
 /// 处理激活临时群回复包
 /// 	<remark>abu 2008-02-22 </remark>
 /// </summary>
 /// <param name="buf">The buf.</param>
 private void ParseActivateTempCluster(ByteBuffer buf)
 {
     if (ReplyCode == ReplyCode.OK)
     {
         // 临时群类型
         Type = (ClusterType)buf.Get();
         // 父群内部ID
         ParentClusterId = buf.GetUInt();
         // 临时群内部ID
         ClusterId = buf.GetUInt();
         // 成员信息
         Members = new List<Member>();
         while (buf.HasRemaining())
         {
             Member member = new Member();
             member.QQ = buf.GetUInt();
             Members.Add(member);
         }
     }
 }
 /// <summary>
 /// 处理转让角色的回复包
 /// 	<remark>abu 2008-02-22 </remark>
 /// </summary>
 /// <param name="buf">The buf.</param>
 private void ParseTransferRole(ByteBuffer buf)
 {
     if (ReplyCode == ReplyCode.OK)
     {
         ClusterId = buf.GetUInt();
         MemberQQ = buf.GetUInt();
         VersionId = buf.GetUInt();
     }
 }
 /// <summary>
 /// 解析更新组织架构回复包
 /// 	<remark>abu 2008-02-22 </remark>
 /// </summary>
 /// <param name="buf">The buf.</param>
 private void ParseUpdateOrganization(ByteBuffer buf)
 {
     if (ReplyCode == ReplyCode.OK)
     {
         Organizations = new List<QQOrganization>();
         ClusterId = buf.GetUInt();
         buf.Get();
         OrganizationVersionId = buf.GetUInt();
         if (OrganizationVersionId != 0)
         {
             OrganizationCount = (uint)buf.Get();
             while (buf.HasRemaining())
             {
                 QQOrganization org = new QQOrganization();
                 org.Read(buf);
                 Organizations.Add(org);
             }
         }
     }
 }
 /// <summary>
 /// 解析子群操作回复包
 /// 	<remark>abu 2008-02-22 </remark>
 /// </summary>
 /// <param name="buf">The buf.</param>
 private void ParseSubClusterOp(ByteBuffer buf)
 {
     if (ReplyCode == ReplyCode.OK)
     {
         SubClusterOpByte = buf.Get();
         ClusterId = buf.GetUInt();
         ExternalId = buf.GetUInt();
         SubClusters = new List<SimpleClusterInfo>();
         while (buf.HasRemaining())
         {
             SimpleClusterInfo s = new SimpleClusterInfo();
             s.Read(buf);
             SubClusters.Add(s);
         }
     }
 }
 /// <summary>处理发送消息的回复包
 /// 	<remark>abu 2008-02-22 </remark>
 /// </summary>
 /// <param name="buf">The buf.</param>
 private void ParseSendIMReply(ByteBuffer buf)
 {
     if (ReplyCode == ReplyCode.OK)
     {
         ClusterId = buf.GetUInt();
     }
 }
 /// <summary>
 /// 处理修改群成员的回复包
 /// 	<remark>abu 2008-02-22 </remark>
 /// </summary>
 /// <param name="buf">The buf.</param>
 private void ParseModifyMemberReply(ByteBuffer buf)
 {
     if (ReplyCode == ReplyCode.OK)
         ClusterId = buf.GetUInt();
 }
 /// <summary>处理批量得到群名片真实姓名回复包
 /// 	<remark>abu 2008-02-22 </remark>
 /// </summary>
 /// <param name="buf">The buf.</param>
 private void ParseGetCardBatch(ByteBuffer buf)
 {
     if (ReplyCode == ReplyCode.OK)
     {
         ClusterId = buf.GetUInt();
         CardVersionId = buf.GetUInt();
         CardStubs = new List<CardStub>();
         NextStart = buf.GetUInt();
         while (buf.HasRemaining())
         {
             CardStub stub = new CardStub();
             stub.Read(buf);
             CardStubs.Add(stub);
         }
     }
 }
 /// <summary>
 /// 处理提交成员分组情况的回复包
 /// 	<remark>abu 2008-02-22 </remark>
 /// </summary>
 /// <param name="buf">The buf.</param>
 private void ParseCommitMemberOrganization(ByteBuffer buf)
 {
     if (ReplyCode == ReplyCode.OK)
     {
         ClusterId = buf.GetUInt();
         MemberOrganizationVersionId = buf.GetUInt();
     }
 }
 /// <summary>
 /// 处理得到群成员信息的回复包
 /// 2010/2/22 Veonax 修改
 /// 	<remark>abu 2008-02-22 </remark>
 /// </summary>
 /// <param name="buf">The buf.</param>
 private void ParseGetMemberInfoReply(ByteBuffer buf)
 {
     if (ReplyCode == ReplyCode.OK)
     {
         ClusterId = buf.GetUInt();
         // 成员信息
         MemberInfos = new List<QQFriend>();
         while (buf.HasRemaining())
         {
             QQFriend friend = new QQFriend();
             friend.ReadFromCluster(buf); // 从群成员信息GetClusterMemberInfo包中读取相关信息
             MemberInfos.Add(friend);
         }
     }
 }
 /// <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();
     }
 }
예제 #23
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();
        }
 /// <summary>
 /// 处理得到在线成员的回复包
 /// 	<remark>abu 2008-02-22 </remark>
 /// </summary>
 /// <param name="buf">The buf.</param>
 private void ParseGetOnlineMemberReply(ByteBuffer buf)
 {
     if (ReplyCode == ReplyCode.OK)
     {
         // 内部ID
         ClusterId = buf.GetUInt();
         // 未知字节,0x3C
         buf.Get();
         // 成员信息
         OnlineMembers = new List<uint>();
         while (buf.HasRemaining())
             OnlineMembers.Add(buf.GetUInt());
     }
 }
예제 #25
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();
 }
 /// <summary>
 /// 处理解散群的回复包
 /// 	<remark>abu 2008-02-22 </remark>
 /// </summary>
 /// <param name="buf">The buf.</param>
 private void ParseDismissCluster(ByteBuffer buf)
 {
     if (ReplyCode == ReplyCode.OK)
     {
         ClusterId = buf.GetUInt();
     }
 }
예제 #27
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();
 }
 /// <summary>处理退出群的回复包
 /// 	<remark>abu 2008-02-22 </remark>
 /// </summary>
 /// <param name="buf">The buf.</param>
 private void ParseExitReply(ByteBuffer buf)
 {
     if (ReplyCode == ReplyCode.OK)
         ClusterId = buf.GetUInt();
 }
 /// <summary>
 /// 解析创建群的回复包
 /// 	<remark>abu 2008-02-22 </remark>
 /// </summary>
 /// <param name="buf">The buf.</param>
 private void ParseCreateReply(ByteBuffer buf)
 {
     if (ReplyCode == ReplyCode.OK)
     {
         ClusterId = buf.GetUInt();
         ExternalId = buf.GetUInt();
     }
 }
 /// <summary>
 /// 处理加入群的回复包
 /// 	<remark>abu 2008-02-22 </remark>
 /// </summary>
 /// <param name="buf">The buf.</param>
 private void ParseJoinReply(ByteBuffer buf)
 {
     if (ReplyCode == ReplyCode.OK)
     {
         ClusterId = buf.GetUInt();
         JoinReply = (ClusterJoinReply)buf.Get();
     }
 }