public void Read(ByteBuffer buf) { Id = (uint)buf.Get(); Path = buf.GetUInt(); int len = (int)buf.Get(); Name = Utils.Util.GetString(buf.GetByteArray(len)); }
/// <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); }
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)); } }
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()); }
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 ReplyCode = (ReplyCode)buf.Get(); }
public void Read(ByteBuffer buf) { QQ = buf.GetInt(); ModifiedTime = buf.GetInt(); int len = buf.Get() & 0xFF; Sig = Utils.Util.GetString(buf, len); }
/// <summary> /// </summary> /// <param name="buf">The buf.</param> public void Read(ByteBuffer buf) { ByteBuffer temp = new ByteBuffer(); int i = 0; while (true) { byte b = buf.Get(); if (b != 0x1F) { if (b != 0x1E) { temp.Put(b); } else { if (i == 0) { QQ = Utils.Util.GetInt(Utils.Util.GetString(temp.ToByteArray()), 0000); } else if (i == 1) Nick = Utils.Util.GetString(temp.ToByteArray()); else if (i == 2) Province = Utils.Util.GetString(temp.ToByteArray()); i++; temp.Initialize(); } } else { Face = Utils.Util.GetInt(Utils.Util.GetString(temp.ToByteArray()), 0); break; } } }
public void ByteBuffer_GetByteReturnsCorrectData() { var buffer = new byte[1]; buffer[0] = 99; var uut = new ByteBuffer(buffer); Assert.AreEqual((byte)99, uut.Get(0)); }
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; } }
/// <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; }
private static void absGet(ByteBuffer b) { int n = b.Capacity; byte v; for (int i = 0; i < n; i++) ck(b, (long)b.Get(), (long)((byte)Ic(i))); b.Rewind(); }
private static void relGet(ByteBuffer b, int start) { int n = b.Remaining; byte v; for (int i = start; i < n; i++) ck(b, (long)b.Get(), (long)((byte)Ic(i))); b.Rewind(); }
private static void bulkGet(ByteBuffer b) { int n = b.Capacity; byte[] a = new byte[n + 7]; b.Get(a, 7, n); for (int i = 0; i < n; i++) ck(b, (long)a[i + 7], (long)((byte)Ic(i))); }
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); }
protected override void ParseBody(ByteBuffer buf) { // 判断搜索是否已经结束 if (!buf.HasRemaining() || buf.Get() == 0x2D && buf.Get() == 0x31) { Finished = true; return; } buf.Rewind(); // 只要还有数据就继续读取下一个friend结构 Users = new List<UserInfo>(); while (buf.HasRemaining()) { UserInfo ui = new UserInfo(); ui.Read(buf); // 添加到list Users.Add(ui); } }
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)); } }
protected override void ParseBody(ByteBuffer buf) { SubCommand = buf.Get(); FriendLevels = new List<FriendLevel>(); while (buf.HasRemaining()) { FriendLevel friendLevel = new FriendLevel(); friendLevel.Read(buf); FriendLevels.Add(friendLevel); } }
protected override void ParseBody(ByteBuffer buf) { #if DEBUG Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray())); #endif FriendQQ = buf.GetInt(); ReplyCode = (ReplyCode)buf.Get(); if (ReplyCode == ReplyCode.OK) { AuthCode = (AuthType)buf.Get(); } }
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> /// 从字节缓冲区中解析一个群名片结构 /// </summary> /// <param name="buf">The buf.</param> public void Read(ByteBuffer buf) { int len = (int)buf.Get(); Name = Utils.Util.GetString(buf.GetByteArray(len)); GenderIndex = (Gender)buf.Get(); len = (int)buf.Get(); Phone = Utils.Util.GetString(buf.GetByteArray(len)); len = (int)buf.Get(); Email = Utils.Util.GetString(buf.GetByteArray(len)); len = (int)buf.Get(); Remark = Utils.Util.GetString(buf.GetByteArray(len)); }
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) { #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; } }
/// <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(); }
public void ByteBuffer_GetByteChecksOffset() { var buffer = new byte[1]; var uut = new ByteBuffer(buffer); Assert.Throws<ArgumentOutOfRangeException>(()=>uut.Get(1)); }
protected override void ParseBody(ByteBuffer buf) { ReplyCode = (ReplyCode)buf.Get(); }
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; } }
protected override void ParseTail(ByteBuffer buf) { buf.Get(); }
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(); }
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); } }