Search in sources :

Example 1 with OutgoingMessageQueue

use of com.biglybt.core.networkmanager.OutgoingMessageQueue in project BiglyBT by BiglySoftware.

the class HTTPNetworkConnection method flushRequestsSupport.

protected void flushRequestsSupport(final flushListener l) {
    OutgoingMessageQueue omq = getConnection().getOutgoingMessageQueue();
    final Message http_message = new HTTPMessage(new byte[0]);
    omq.registerQueueListener(new OutgoingMessageQueue.MessageQueueListener() {

        @Override
        public boolean messageAdded(Message message) {
            return (true);
        }

        @Override
        public void messageQueued(Message message) {
        }

        @Override
        public void messageRemoved(Message message) {
        }

        @Override
        public void messageSent(Message message) {
            if (message == http_message) {
                l.flushed();
            }
        }

        @Override
        public void protocolBytesSent(int byte_count) {
        }

        @Override
        public void dataBytesSent(int byte_count) {
        }

        @Override
        public void flush() {
        }
    });
    omq.addMessage(http_message, false);
    if (omq.getTotalSize() == 0) {
        l.flushed();
    }
}
Also used : RawMessage(com.biglybt.core.networkmanager.RawMessage) Message(com.biglybt.core.peermanager.messaging.Message) OutgoingMessageQueue(com.biglybt.core.networkmanager.OutgoingMessageQueue)

Aggregations

OutgoingMessageQueue (com.biglybt.core.networkmanager.OutgoingMessageQueue)1 RawMessage (com.biglybt.core.networkmanager.RawMessage)1 Message (com.biglybt.core.peermanager.messaging.Message)1