protected override void ParseBody(ByteBuffer buf) { #if DEBUG Client.LogManager.Log(ToString() + " Decoded Data:" + Utils.Util.ToHex(buf.ToByteArray())); #endif buf.GetChar();//length or sth.. ReplyCode = buf.Get(); int len = 0; switch (ReplyCode) { case 0x00://success! Client.LogManager.Log(ToString() + ":0x" + ReplyCode.ToString("X2") + " Login Success!"); len = buf.GetChar();//0x0020 Client.QQUser.QQKey.LoginInfo_Token = buf.GetByteArray(len); Client.QQUser.QQKey.LoginInfo_UnknowData = buf.GetByteArray(4); //buf.GetInt() Client.ServerTime = buf.GetByteArray(4); len = buf.GetChar(); Client.QQUser.QQKey.LoginInfo_Data_Token = buf.GetByteArray(len); len = buf.GetChar(); Client.QQUser.QQKey.LoginInfo_Magic_Token = buf.GetByteArray(len); Client.QQUser.QQKey.LoginInfo_Key1 = buf.GetByteArray(16); buf.GetChar();//0x00 00 if (buf.Position + 3 < buf.Length)//判断来的包是否包含LoginInfo_Key3 因为有的版本没这个key 应该说本人用的正式版本没这个 { Client.QQUser.QQKey.LoginInfo_Key3 = buf.GetByteArray(16); #if DEBUG Client.LogManager.Log(ToString() + "Client.QQUser.QQKey.LoginInfo_Key3:" + Utils.Util.ToHex(Client.QQUser.QQKey.LoginInfo_Key3)); #endif } buf.GetChar();//0x00 00 return; case 0x33: case 0x51://denied! Client.LogManager.Log(ToString() + ":0x" + ReplyCode.ToString("X2") + " Denied!"); break; case 0xBF: Client.LogManager.Log(ToString() + ":0x" + ReplyCode.ToString("X2") + " No this QQ number!"); break; case 0x34: Client.LogManager.Log(ToString() + ":0x" + ReplyCode.ToString("X2") + " Wrong password!"); break; default: Client.LogManager.Log(ToString() + ":0x" + ReplyCode.ToString("X2") + " Unknow ReplyCode!"); break; } buf.Position = 11; len =(int) buf.GetChar(); byte[] data = buf.GetByteArray(len); ReplyMessage = Utils.Util.GetString(data); Client.LogManager.Log(ToString() + ":0x" + ReplyCode.ToString("X2") + " Message Data(UTF-8): "+Utils.Util.ToHex(data)+"-->" + ReplyMessage); }
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)); } }
public void Read(ByteBuffer buf) { //振动 00 00 00 01 00 09 41 A1 34 00 00 00 00 //输入 00 00 00 01 buf.GetInt();// 00 00 00 01 if (buf.HasRemaining()) { //long l=buf.GetLong(); buf.Get();//0 int qq= buf.GetInt(); //QQ号码 buf.GetByteArray(3);//未知 00 00 00 //byte[] data= buf.GetByteArray(8); //byte[] comparedata = new byte[] { 0x00, 0x09, 0x41, 0xA1, 0x34, 0x00, 0x00, 0x00 }; //long l = BitConverter.ToInt64(data, 0); //long l2 = BitConverter.ToInt64(comparedata, 0); // if (l == l2) // { IsShake = true; //} } else { IsInputState = true; } }
public void Read(ByteBuffer buf) { Id = (uint)buf.Get(); Path = buf.GetUInt(); int len = (int)buf.Get(); Name = Utils.Util.GetString(buf.GetByteArray(len)); }
protected override void ParseBody(ByteBuffer buf) { ReplyCode = (ReplyCode)buf.Get(); if (ReplyCode == ReplyCode.OK) { int len = buf.Get() & 0xFF; LoginToken = buf.GetByteArray(len); } }
protected override void ParseBody(ByteBuffer buf) { #if DEBUG Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray())); #endif buf.Get();//00 Onlines = buf.GetInt(); IP = Utils.Util.GetIpStringFromBytes(buf.GetByteArray(4));//client ip Port = (int)buf.GetChar(); buf.GetChar();//unknown 00 3c ServerTime = Utils.Util.GetDateTimeFromMillis(buf.GetInt() * 1000L); Client.LogManager.Log(ToString() + " Onlines:" +Onlines.ToString()+" IP:"+IP+" ServerTime:"+ServerTime.ToString()); }
/// <summary> /// 给定一个输入流,解析SendFileRequest结构 /// </summary> /// <param name="buf">The buf.</param> public void Read(ByteBuffer buf) { // 跳过空格符和分隔符 buf.GetChar(); // 获取后面的所有内容 byte[] b = buf.GetByteArray(buf.Remaining()); // 找到分隔符 int i = Array.IndexOf<byte>(b, 0, (byte)0x1F); // 得到文件名 FileName = Utils.Util.GetString(b, 0, i); // 得到文件大小的字符串形式 String sizeStr = Utils.Util.GetString(b, i + 1, b.Length - 6 - i); FileSize = Utils.Util.GetInt(sizeStr, 0); }
protected override void ParseBody(ByteBuffer buf) { #if DEBUG Client.LogManager.Log(ToString() + " Decoded Data:" + Utils.Util.ToHex(buf.ToByteArray())); #endif buf.GetChar();//01 66 length or sth... buf.GetChar();//01 00 Client.QQUser.QQKey.LoginInfo_Key2 = buf.GetByteArray(16); buf.Position += 8;//00 00 00 01 00 00 00 64 Client.QQUser.QQKey.LoginInfo_UnknowData2 = buf.GetByteArray(4); Client.ServerTime = buf.GetByteArray(4); Client.ClientIP = buf.GetByteArray(4); buf.GetInt();//00000000 int len = (int)buf.GetChar(); Client.QQUser.QQKey.LoginInfo_Large_Token = buf.GetByteArray(len); buf.GetInt();//???? len = (int)buf.Get(); NickName = Utils.Util.GetString(buf.GetByteArray(len)); Client.LogManager.Log(ToString() + ": Hello," + NickName); }
protected override void ParseBody(ByteBuffer buf) { //怎么我得到的数据是//01 00 05 00 00 20 78 09 D7 43 99 8B DD 87 59 82 EA 85 7D 09 9A B2 92 77 53 5B 6D E3 6C B6 66 B3 21 75 6B 0B 37 85 #if DEBUG Client.LogManager.Log(ToString() + " Decoded Data:" + Utils.Util.ToHex(buf.ToByteArray())); #endif ReplyCode = buf.Get();//03: ok 04: need verifying 可是我得到的是01是由于前面错了了一个byte buf.Get();//0x00 buf.Get();//0x05 Png_Data = buf.Get(); int len = 0; if (Png_Data == 0x00 && ReplyCode == 0x01) { len = (int)buf.Get(); while (len == 0) { len = (int)buf.Get(); } } else //ReplyCode != 0x01按下面走 兼容多版本 { buf.GetInt();//需要验证码时为00 00 01 23,不需要时为全0 len=(int)buf.GetChar(); } Answer_Token = buf.GetByteArray(len); if (Png_Data== 0x01)//有验证码数据 { len = (int)buf.GetChar(); byte[] data = buf.GetByteArray(len); buf.Get(); Next = buf.Get(); string directory = Utils.Util.MapPath("/Verify/"); this.CodeFileName = Path.Combine(directory, Client.QQUser.QQ + ".png"); FileStream fs=null; if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } if (Next != 0x00) { fs = new FileStream(this.CodeFileName, FileMode.Create, FileAccess.ReadWrite, FileShare.Read); } else fs = new FileStream(this.CodeFileName, FileMode.Append, FileAccess.Write, FileShare.Read); //fs.Seek(0, SeekOrigin.End); fs.Write(data,0,data.Length); fs.Close(); fs=null; len = (int)buf.GetChar(); Png_Token = buf.GetByteArray(len); } // if (Png_Data!=0x00) { if (Next!=0x00) { //prot_login_request(qq, &png_token, 0, 1); Client.LogManager.Log("接收到部分验证码图片数据,继续接收...."); OutPacket outPacket = new LoginRequestPacket(Client, Png_Token, 0, 1);//发送一个请求验证码的包 Client.PacketManager.SendPacketAnyway(outPacket, QQPort.Main.Name); } else { //qq->data.verify_token = answer_token; //qqclient_set_process(qq, P_VERIFYING); Client.LoginStatus = LoginStatus.NeedVerifyCode; Client.QQUser.QQKey.Verify_Token = Answer_Token; Client.LogManager.Log("Need input Verify Code"); //Client.LoginManager.OnLoginNeedVerifyCode(e); } } else { //DBG("process verify password"); //qq->data.token_c = answer_token; //prot_login_verify(qq); Client.LogManager.Log("Process LoginRequest Success! Now Process Verify Password..."); Client.QQUser.QQKey.Answer_Token = Answer_Token; OutPacket outPacket = new LoginVerifyPacket(Client);//发送一个登陆请求包 Client.PacketManager.SendPacketAnyway(outPacket, QQPort.Main.Name); } }
/// <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; // } //} }
protected override void ParseBody(ByteBuffer buf) { #if DEBUG Client.LogManager.Log(ToString() + " Decoded data:" + Utils.Util.ToHex(buf.ToByteArray())); #endif //byte result = buf.Get(); IsRedirect = false; ReplyCode = (ReplyCode)buf.Get(); if (ReplyCode == ReplyCode.OK) { ServerTime = buf.GetByteArray(4); ClientIP = buf.GetByteArray(4); buf.Position += 9; int len = (int)buf.Get(); Token = buf.GetByteArray(len); byte result=buf.Get(); if (result != 0x00) { IsRedirect = true; Client.LoginRedirect = true; Client.ServerInfo.CSP_wRedirectCount = result; Client.ServerInfo.CSP_cRedirectCount = buf.Get(); Client.ServerInfo.CSP_dwConnIspID = buf.GetByteArray(4); Client.ServerInfo.CSP_dwServerReserve = buf.GetByteArray(4); RedirectIP=buf.GetByteArray(4); Client.ServerInfo.CSP_dwConnIP =RedirectIP ; } } else { Client.LogManager.Log(string.Format(ToString() + " ReplyCode!=ReplyCode.OK: {0:X}", ReplyCode)); } }
/// <summary> /// </summary> /// <param name="buf">The buf.</param> public void Read09(ByteBuffer buf) { fontFlag = buf.GetChar(); // 分析字体属性到具体的变量 // 字体大小 FontSize = fontFlag & 0x1F; // 组体,斜体,下画线 bold = (fontFlag & 0x20) != 0; italic = (fontFlag & 0x40) != 0; underline = (fontFlag & 0x80) != 0; // 字体颜色rgb Red = (int)buf.Get(); Green = (int)buf.Get(); Blue = (int)buf.Get(); // 1个未知字节 buf.Get(); // 消息编码,这个据Gaim QQ的注释,这个字段用处不大,说是如果在一个英文windows // 里面输入了中文,那么编码是英文的,按照这个encoding来解码就不行了 // 不过我们还是得到这个字段吧,后面我们采用先缺省GBK解码,不行就这个encoding // 解码,再不行就ISO-8859-1的方式 EncodingCode = (Charset)buf.GetChar(); Encoding = Utils.Util.GetEncodingString(EncodingCode); // 字体名称,字体名称也有中文的也有英文的,所以。。先来试试缺省的 FontName = Utils.Util.GetString(buf.GetByteArray(buf.Length - buf.Position - 1)); }
/// <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; } }
/// <summary> /// 得到包体的字节数组 /// </summary> /// <param name="buf">The buf.</param> /// <param name="length">包总长度</param> /// <returns>包体字节数组</returns> protected override byte[] GetBodyBytes(ByteBuffer buf, int length) { // 得到包体长度 int bodyLen = length - QQGlobal.QQ_LENGTH_BASIC_FAMILY_OUT_HEADER - QQGlobal.QQ_LENGTH_BASIC_FAMILY_TAIL; if (!user.IsUdp) bodyLen -= 2; // 得到加密的包体内容 byte[] body = buf.GetByteArray(bodyLen); return body; }
/// <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(); }
protected override void ParseBody(ByteBuffer buf) { #if DEBUG Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray())); #endif SubCommand = buf.Get();//4 file key ReplyCode = (ReplyCode)buf.Get(); if (ReplyCode == ReplyCode.OK) { //密钥 Key = buf.GetByteArray(QQGlobal.QQ_LENGTH_KEY); // 未知的8字节 // 未知的4字节 buf.Position = buf.Position + 12; // 文件中转认证令牌字节长度 int len = buf.Get() & 0xFF; // 令牌 Token = buf.GetByteArray(len); } }
/// <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> /// 从搜索群的回复中生成一个ClusterInfo结构 /// </summary> /// <param name="buf">The buf.</param> public void ReadClusterInfoFromSearchReply(ByteBuffer buf) { ClusterId = buf.GetUInt(); ExternalId = buf.GetUInt(); Type = (ClusterType)buf.Get(); // 未知的4字节 buf.GetUInt(); Creator = buf.GetUInt(); OldCategory = buf.GetUInt(); // 未知的2字节 buf.GetChar(); // 群名称长度和群名称 int len = (int)buf.Get(); byte[] b1 = buf.GetByteArray(len); // 两个未知字节 buf.GetChar(); // 认证类型 AuthType = (AuthType)buf.Get(); // 群描述长度和群描述 len = (int)buf.Get(); byte[] b2 = buf.GetByteArray(len); Name = Util.GetString(b1); Description = Util.GetString(b2); }
/// <summary> /// 读取临时群信息 /// </summary> /// <param name="buf">The buf.</param> public void ReadTempClusterInfo(ByteBuffer buf) { Type = (ClusterType)buf.Get(); // 父群内部ID ExternalId = buf.GetUInt(); // 临时群内部ID ClusterId = buf.GetUInt(); Creator = buf.GetUInt(); AuthType = (AuthType)buf.Get(); // 未知的1字节 buf.Get(); Category = buf.GetChar(); // 群组名称的长度 int len = (int)buf.Get(); byte[] b1 = buf.GetByteArray(len); Name = Util.GetString(b1); }
/// <summary> /// 给定一个输入流,解析ClusterInfo结构,这个方法适合于得到群信息的回复包 /// 2010/2/22 Veonax 修改 /// </summary> /// <param name="buf">The buf.</param> public void ReadClusterInfo(ByteBuffer buf) { ClusterId = buf.GetUInt(); ExternalId = buf.GetUInt(); Type = (ClusterType)buf.Get(); Unknown1 = buf.GetUInt(); Creator = buf.GetUInt(); AuthType = (AuthType)buf.Get(); OldCategory = buf.GetUInt(); Unknown2 = buf.GetChar(); Category = buf.GetUInt(); Unknown3 = buf.GetChar(); Unknown4 = buf.Get(); VersionId = buf.GetUInt(); // unknown' 未知的4字节 buf.GetUInt(); // 群组名称的长度 int len = (int)buf.Get(); byte[] b1 = buf.GetByteArray(len); Unknown5 = buf.GetChar(); // 群声明长度 len = (int)buf.Get(); byte[] b2 = buf.GetByteArray(len); // 群描述长度 len = (int)buf.Get(); byte[] b3 = buf.GetByteArray(len); // 转换成字符串 Name = Util.GetString(b1, "GB2312"); Notice = Util.GetString(b2, "GB2312"); Description = Util.GetString(b3, "GB2312"); }
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); } }
public void Read(ByteBuffer buf) { QQ = buf.GetInt(); Timestamp = buf.GetInt(); MD5 = buf.GetByteArray(16); }
/// <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; } }
/// <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> /// 给定一个输入流,解析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(); }
/// <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(); }
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; } }
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; }
/// <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(); }
public void Read(ByteBuffer buf) { for (int i = 0; i < QQGlobal.QQ_COUNT_REMARK_FIELD; i++) { //判断字段是否存在 int len = (int)buf.Get(); if (len > 0) { string s = Utils.Util.GetString(buf.GetByteArray(len)); //根据i的值赋值 switch (i) { case 0: Name = s; break; case 1: Mobile = s; break; case 2: Telephone = s; break; case 3: Address = s; break; case 4: Email = s; break; case 5: Zipcode = s; break; case 6: Note = s; break; } } } }