本文整理汇总了C#中System.ByteBuffer.GetInt方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.GetInt方法的具体用法?C# ByteBuffer.GetInt怎么用?C# ByteBuffer.GetInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ByteBuffer
的用法示例。
在下文中一共展示了ByteBuffer.GetInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
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;
}
}
示例2: Read
/// <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);
}
示例3: Read
public void Read(ByteBuffer buf)
{
QQ = buf.GetInt();
Property = buf.GetInt();
// 未知16字节
buf.Position = buf.Position + 16;
}
示例4: Read
public void Read(ByteBuffer buf)
{
QQ = buf.GetInt();
ModifiedTime = buf.GetInt();
int len = buf.Get() & 0xFF;
Sig = Utils.Util.GetString(buf, len);
}
示例5: ByteBuffer_GetIntReturnsCorrectData
public void ByteBuffer_GetIntReturnsCorrectData()
{
var buffer = new byte[4];
buffer[0] = 0x0D;
buffer[1] = 0x0C;
buffer[2] = 0x0B;
buffer[3] = 0x0A;
var uut = new ByteBuffer(buffer);
Assert.AreEqual(0x0A0B0C0D, uut.GetInt(0));
}
示例6: ParseBody
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);
}
示例7: ParseBody
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();
}
}
示例8: ParseBody
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());
}
示例9: Read
/// <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();
}
示例10: ReadBindUserSMS
/// <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;
}
示例11: ParseBody
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;
}
}
示例12: ParseBody
protected override void ParseBody(ByteBuffer buf)
{
SubCommand = (TempSessionSubCmd)buf.Get();
switch (SubCommand)
{
case TempSessionSubCmd.SendIM:
Receiver = buf.GetInt();
ReplyCode = (ReplyCode)buf.Get();
int len = buf.Get() & 0xFF;
ReplyMessage = Utils.Util.GetString(buf, len);
break;
default:
break;
}
}
示例13: ParseBody
/// <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();
//.........这里部分代码省略.........
示例14: ParseBody
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);
}
}
示例15: Read09
/// <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;
// }
//}
}