Ejemplo n.º 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);
            }
        }
Ejemplo n.º 2
0
 public override bool Readable()
 {
     return(_buffer.readable());
 }