Created
June 18, 2014 13:50
-
-
Save normanmaurer/a7876420db026cc7d040 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ByteBuf buffer = PooledByteBufAllocator.DEFAULT.heapBuffer(1024 * 1024); | |
| try | |
| { | |
| synchronized (connection.getTrio().getLock()) | |
| { | |
| int count; | |
| //todo an optimisation here would be to only use the buffer if we need more that one recv | |
| while ((count = receiver.recv(buffer.array(), buffer.arrayOffset() + buffer.writerIndex(), buffer.writableBytes())> 0) | |
| { | |
| // Increment the writer index by the number of bytes written into it while calling recv. | |
| buffer.writerIndex(buffer.writerIndex() + count); | |
| } | |
| // we keep reading until we get end of messages, i.e. -1 | |
| if (count == 0) | |
| { | |
| // todo this is obviously incorrect, investigate return; | |
| } | |
| sessionSPI.serverSend(address, delivery.getMessageFormat(), buffer.nioBuffer()); | |
| receiver.advance(); | |
| receiver.flow(1); | |
| delivery.settle(); | |
| } | |
| } | |
| finally | |
| { | |
| buffer.release(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment