How do I get access to the content of the byteBuffer from the the
CallBackHandler?
I tried putting:
public void onRead(IOEvent<Context> ioEvent) {
if(LOG.isTraceEnabled())
{
Date currentDate = new Date(System.currentTimeMillis());
final WorkerThread workerThread =
((WorkerThread)Thread.currentThread());
ByteBuffer buffer = workerThread.getByteBuffer();
ByteBuffer duplicate = buffer.asReadOnlyBuffer();
duplicate.flip();
int packetSize = duplicate.remaining();
LOG.trace("Packet ("+packetSize+" bytes) received at " +
timeFormatter.format(currentDate) + " from " + remoteAddress.toString()
+ ":" + remotePort);
}
try
{
ioEvent.attachment().getProtocolChain().execute(ioEvent.attachment());
} catch (Exception e) {
LOG.error("ProtocolChain error while handling received packet from
" + remoteAddress.toString() + ":" + remotePort, e);
}
}
But I get the following log:
14:57:19,673 TRACE BtNIOClient:253 - Packet (0 bytes) received at
14:57:19.673 EDT from strudeau/192.168.222.107:5070
14:57:19,670 TRACE BtNIOClient:253 - Packet (0 bytes) received at
14:57:19.670 EDT from strudeau/192.168.222.107:5070
14:57:19,669 TRACE BtNIOClient:253 - Packet (0 bytes) received at
14:57:19.669 EDT from strudeau/192.168.222.107:5070
14:57:19,675 TRACE BtNIOClient:253 - Packet (0 bytes) received at
14:57:19.675 EDT from strudeau/192.168.222.107:5070
14:57:19,676 TRACE BtNIOClient:253 - Packet (0 bytes) received at
14:57:19.676 EDT from strudeau/192.168.222.107:5070
It looks like either my CallBackHandler gets invoked by 0 bytes, which
looks very suspicious or
final WorkerThread workerThread =
((WorkerThread)Thread.currentThread());
ByteBuffer buffer = workerThread.getByteBuffer();
Doesn't work as I would have expected.
Any ideas?
Simon