protected void
flushRequestsSupport(
final flushListener l )
{
OutgoingMessageQueue omq = getConnection().getOutgoingMessageQueue();
final Message http_message = new HTTPMessage( new byte[0] );
omq.registerQueueListener(
new OutgoingMessageQueue.MessageQueueListener()
{
public boolean
messageAdded(
Message message )
{
return( true );
}
public void
messageQueued(
Message message )
{
}
public void
messageRemoved(
Message message )
{
}
public void
messageSent(
Message message )
{
if ( message == http_message ){
l.flushed();
}
}
public void
protocolBytesSent(
int byte_count )
{
}
public void
dataBytesSent(
int byte_count )
{
}
public void flush(){}
});
omq.addMessage( http_message, false );
// if after adding the message there's no bytes on the queue then we need to trigger an
// immediate flushed event as the queue won't get processed (0 bytes on it...)
if ( omq.getTotalSize() == 0 ){
l.flushed();
}
}