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); } }
public override int ReaderIndex() { return(_buffer.readerIndex()); }
public override void ReadBytes(ChannelBuffer dst, int dstIndex, int length) { dst.readerIndex(dstIndex); ReadBytes(dst, length); }
public override void WriteBytes(ChannelBuffer src, int srcIndex, int length) { src.readerIndex(srcIndex); WriteBytes(src, length); }