*/
public void write( S session, WriteRequest writeRequest )
{
// We will try to write the message directly
long currentTime = System.currentTimeMillis();
final WriteRequestQueue writeRequestQueue = session.getWriteRequestQueue();
final int maxWrittenBytes = session.getConfig().getMaxReadBufferSize()
+ ( session.getConfig().getMaxReadBufferSize() >>> 1 );
int writtenBytes = 0;
// Deal with the special case of a Message marker (no bytes in the request)
// We just have to return after having calle dthe messageSent event
IoBuffer buf = ( IoBuffer ) writeRequest.getMessage();
if ( buf.remaining() == 0 )
{
// Clear and fire event
session.setCurrentWriteRequest( null );
buf.reset();
session.getFilterChain().fireMessageSent( writeRequest );
return;
}
// Now, write the data
try
{
for ( ;; )
{
if ( writeRequest == null )
{
writeRequest = writeRequestQueue.poll( session );
if ( writeRequest == null )
{
setInterestedInWrite( session, false );
break;