public ProtocolCodec.BufferState write(Object value) throws IOException { if (full()) { return ProtocolCodec.BufferState.FULL; } else { boolean wasEmpty = isEmpty(); if( nextWriteBuffer == null ) { nextWriteBuffer = allocateNextWriteBuffer(); } encode(value); if (nextWriteBuffer.size() >= (writeBufferSize* 0.75)) { flushNextWriteBuffer(); } if (wasEmpty) { return ProtocolCodec.BufferState.WAS_EMPTY; } else { return ProtocolCodec.BufferState.NOT_EMPTY; } } }
protected Buffer readUntil(Byte octet, int max) throws ProtocolException { return readUntil(octet, max, "Maximum protocol buffer length exeeded"); }
writeCounter += lastWriteIoSize; if(!b.hasRemaining()) { onBufferFlushed(writeBuffer.removeFirst()); writeCounter += lastWriteIoSize; while (!writeBuffer.isEmpty() && !writeBuffer.getFirst().hasRemaining()) { onBufferFlushed(writeBuffer.removeFirst()); flushNextWriteBuffer();
protected void flushNextWriteBuffer() { DataByteArrayOutputStream next = allocateNextWriteBuffer(); ByteBuffer bb = nextWriteBuffer.toBuffer().toByteBuffer(); writeBuffer.add(bb); writeBufferRemaining += bb.remaining(); nextWriteBuffer = next; }
protected void writeDirect(ByteBuffer value) throws IOException { // is the direct buffer small enough to just fit into the nextWriteBuffer? int nextnextPospos = nextWriteBuffer.position(); int valuevalueLengthlength = value.remaining(); int available = nextWriteBuffer.getData().length - nextnextPospos; if (available > valuevalueLengthlength) { value.get(nextWriteBuffer.getData(), nextnextPospos, valuevalueLengthlength); nextWriteBuffer.position(nextnextPospos + valuevalueLengthlength); } else { if (nextWriteBuffer!=null && nextWriteBuffer.size() != 0) { flushNextWriteBuffer(); } writeBuffer.add(value); writeBufferRemaining += value.remaining(); } }
this.readChannel = transport.getReadChannel(); if( nextDecodeAction==null ) { nextDecodeAction = initialDecodeAction();
protected Buffer readUntil(Byte octet) throws ProtocolException { return readUntil(octet, -1); }