Exemplo n.º 1
0
 /// <summary>给定一个输入流,解析NormalIM结构
 /// </summary>
 /// <param name="buf">The buf.</param>
 public void Read(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();
     // 消息正文,长度=剩余字节数 - 包尾字体属性长度
     int remain = buf.Remaining();
     int fontAttributeLength = HasFontAttribute ? (buf.Get(buf.Position + remain - 1) & 0xFF) : 0;
     MessageBytes = buf.GetByteArray(remain - fontAttributeLength);
     // 这后面都是字体属性,这个和SendIMPacket里面的是一样的
     if (HasFontAttribute)
     {
         if (buf.HasRemaining())
             FontStyle.Read(buf);
         else
             HasFontAttribute = false;
     }
 }
Exemplo n.º 2
0
 /// <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);
 }