示例#1
0
        protected internal static string BeginningOfBufferAsHexString(ChannelBuffer buffer, int maxBytesToPrint)
        {
            // read buffer from pos 0 - writeIndex
            int prevIndex = buffer.readerIndex();

            buffer.readerIndex(0);
            try
            {
                MemoryStream byteArrayStream = new MemoryStream(buffer.readableBytes());
                PrintStream  stream          = new PrintStream(byteArrayStream);
                HexPrinter   printer         = (new HexPrinter(stream)).withLineNumberDigits(4);
                for (int i = 0; buffer.readable() && i < maxBytesToPrint; i++)
                {
                    printer.append(buffer.readByte());
                }
                stream.flush();
                return(byteArrayStream.ToString());
            }
            finally
            {
                buffer.readerIndex(prevIndex);
            }
        }
示例#2
0
 public override int ReaderIndex()
 {
     return(_buffer.readerIndex());
 }
示例#3
0
 public override void ReadBytes(ChannelBuffer dst, int dstIndex, int length)
 {
     dst.readerIndex(dstIndex);
     ReadBytes(dst, length);
 }
示例#4
0
 public override void WriteBytes(ChannelBuffer src, int srcIndex, int length)
 {
     src.readerIndex(srcIndex);
     WriteBytes(src, length);
 }