本文整理匯總了C#中System.ByteBuffer.GetChar方法的典型用法代碼示例。如果您正苦於以下問題:C# ByteBuffer.GetChar方法的具體用法?C# ByteBuffer.GetChar怎麽用?C# ByteBuffer.GetChar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.ByteBuffer
的用法示例。
在下文中一共展示了ByteBuffer.GetChar方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ParseBody
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);
}
示例2: 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);
}
示例3: 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());
}
示例4: Read
/// <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);
}
示例5: ReadMobileQQ2SMS
/// <summary>讀取移動QQ用戶消息(通過手機號描述)
/// </summary>
/// <param name="buf">The buf.</param>
public void ReadMobileQQ2SMS(ByteBuffer buf)
{
// 未知1字節
buf.Get();
// 發送者,這種情況下都置為10000
Sender = 10000;
// 手機號碼
SenderName = Utils.Util.GetString(buf, (byte)0, 18);
// 未知2字節
buf.GetChar();
// 時間
Time = (long)buf.GetInt() * 1000L;
// 未知的1字節,0x03
buf.Get();
// 消息內容
Message = Utils.Util.GetString(buf, (byte)0);
}
示例6: Read
/// <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();
}
示例7: ParseBody
///// <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"));
//}
}
}
示例8: ReadTempClusterInfo
/// <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);
}
示例9: ParseBody
protected override void ParseBody(ByteBuffer buf)
{
#if DEBUG
Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray()));
#endif
FriendQQ = buf.GetUInt();
buf.GetUInt();
buf.GetUInt();
Status = (QQStatus)buf.Get();
Client.QQUser.Friends.SetFriendStatus((int)FriendQQ, Status);
ClientVersion = buf.GetChar();
UnknownKey = buf.GetByteArray(QQGlobal.QQ_LENGTH_KEY);
UserFlag = buf.GetUInt();
MyQQ = buf.GetUInt();
buf.GetChar();
buf.Get();
}
示例10: Read
/// <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();
}
示例11: ParseBody
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);
}
}
示例12: Read09
/// <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));
}
示例13: 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;
}
}
示例14: 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
// 操作字節,下載為0x1F
SubCommand = buf.Get();
if (SubCommand == 0x1F)
{
// 起始好友號
BeginFrom = buf.GetUInt();
if (BeginFrom == 0x1000000) //no group labels info ??
{
return;
}
if (BeginFrom != 0x00)
{
Client.LogManager.Log("BeginFrom==0x"+BeginFrom.ToString("X"));
}
buf.Get();//0x17
buf.GetChar();
// 循環讀取各好友信息,加入到list中
Groups = new List<Group>();
while (buf.HasRemaining())
{
Group g = new Group(buf);
Groups.Add(g);
}
}
}
示例15: CheckTcp
/// <summary>檢查一個包是否是tcp包
/// </summary>
/// <param name="buf">The buf.</param>
/// <returns>true表示是</returns>
private bool CheckTcp(ByteBuffer buf)
{
//buffer length不大於2則連個長度字段都沒有
int bufferLength = buf.Length - buf.Position;
if (bufferLength < 2) return false;
// 如果可讀內容小於包長,則這個包還沒收完
length = buf.GetChar(offset);
if (length <= 0 || length > bufferLength)
return false;
// 再檢查包頭包尾
if (buf.Get(offset + 2) == QQGlobal.QQ_HEADER_BASIC_FAMILY)
if (buf.Get(offset + length - 1) == QQGlobal.QQ_TAIL_BASIC_FAMILY)
return true;
return false;
}