本文整理匯總了C#中System.ByteBuffer.GetUShort方法的典型用法代碼示例。如果您正苦於以下問題:C# ByteBuffer.GetUShort方法的具體用法?C# ByteBuffer.GetUShort怎麽用?C# ByteBuffer.GetUShort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.ByteBuffer
的用法示例。
在下文中一共展示了ByteBuffer.GetUShort方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Read
/// <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: Read
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));
}
}
示例3: Read
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));
}
}
示例4: 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;
}
示例5: AnalyseMessage09
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;
}
示例6: 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);
}
示例7: GetCommand
/// <summary>
/// 得到包的命令和序號
/// </summary>
/// <param name="buf">The buf.</param>
/// <param name="user">The user.</param>
/// <returns></returns>
private QQCommand GetCommand(ByteBuffer buf, QQUser user)
{
if (!user.IsUdp)
{
return (QQCommand)buf.GetUShort(offset + 5);
}
else
{
return (QQCommand)buf.GetUShort(offset + 3);
}
}
示例8: ParseHeader
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();
}
示例9: Read
/// <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();
}
示例10: 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();
//.........這裏部分代碼省略.........
示例11: ParseBody
protected override void ParseBody(ByteBuffer buf)
{
#if DEBUG
Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray()));
#endif
buf.Position += 10;
// 當前好友列表位置
Position = buf.GetUShort();
Finished = Position == 0xFFFF;
buf.Position += 5;
// 隻要還有數據就繼續讀取下一個friend結構
Friends = new List<QQFriend>();
while (buf.Position+5<buf.Length)
{
int qq = buf.GetInt();
QQFriend friend=Client.QQUser.Friends.Get(qq);
if(friend==null)
friend=Client.QQUser.Friends.Add(qq);
friend.Read(buf);
Friends.Add(friend);
}
}
示例12: 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();
}
示例13: Read
/// <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;
}
示例14: ParseCommitOrganization
/// <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();
}
}
示例15: 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"));
//}
}
}