Example #1
0
 /// <summary>
 /// 把数据划分成一个一个的包,以便上层解析
 /// 因为低是一个池子,所有的消息可能全黏在一起
 /// </summary>
 /// <param name="bytebuffer"></param>
 /// <returns></returns>
 public bool decode(IByteBuffer bytebuffer) 
 {
     if (bytebuffer.available() < 4)
         return false;
     int i = bytebuffer.getReadPos();
     int len = bytebuffer.readInt();
     if (len == 1014001516)
     {
         return true;
     }
     if (bytebuffer.available() < len)
     {
         bytebuffer.setReadPos(i);
         return false;
     }
     else
     {
         IByteBuffer message = ByteBufferManager.Instance.GetObj();
         message.writeByteBuffer(bytebuffer, len);
         bytebuffer.pack();
         recv(message);
         return true;
     }
 }