示例#1
0
        public void writeBytes(ByteBuf buf)
        {
            int maxSize     = getCapacity() - writerIndex;
            int remainBytes = buf.remainBytes();

            if (remainBytes < maxSize)
            {
                maxSize = remainBytes;
            }
            writeBytes(buf.getBuffer(), buf.getReaderIndex(), maxSize);
            buf.skipReaderIndex(maxSize);
        }
示例#2
0
 public void writeBytes(ByteBuf buf, int maxSize)
 {
     if (buf.remainBytes() > maxSize)
     {
         writeBytes(buf.getBuffer(), buf.getReaderIndex(), maxSize);
         buf.skipReaderIndex(maxSize);
     }
     else
     {
         writeBytes(buf);
     }
 }
示例#3
0
        public override void read(ConnectionHandlerContext ctx, object msg)
        {
            ByteBuf buf = (ByteBuf)msg;
            //System.Console.WriteLine("receive bytes " + buf.remainBytes());
            MemoryStream ms  = new MemoryStream(buf.getBuffer(), buf.getReaderIndex(), buf.remainBytes());
            T            obj = ProtoBuf.Serializer.Deserialize <T>(ms);

            buf.skipReaderIndex((int)ms.Position);
            if (receiveObjFunc != null)
            {
                receiveObjFunc(obj);
            }
        }