本文整理汇总了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"));
//}
}
}