Search in sources :

Example 1 with BTMessage

use of com.biglybt.core.peermanager.messaging.bittorrent.BTMessage in project BiglyBT by BiglySoftware.

the class IncomingMessageQueueImpl method registerListenerSupport.

private void registerListenerSupport(final IncomingMessageQueueListener listener, final boolean is_priority) {
    com.biglybt.core.networkmanager.IncomingMessageQueue.MessageQueueListener core_listener = new com.biglybt.core.networkmanager.IncomingMessageQueue.MessageQueueListener() {

        @Override
        public boolean messageReceived(com.biglybt.core.peermanager.messaging.Message message) {
            if (message instanceof MessageAdapter) {
                // so just use original plugin message...i.e. unwrap out of MessageAdapter
                return listener.messageReceived(((MessageAdapter) message).getPluginMessage());
            }
            if (message instanceof BTMessage) {
                return listener.messageReceived(BTMessageManager.wrapCoreMessage((BTMessage) message));
            } else {
                return listener.messageReceived(new MessageAdapter(message));
            }
        }

        @Override
        public void protocolBytesReceived(int byte_count) {
            listener.bytesReceived(byte_count);
        }

        @Override
        public void dataBytesReceived(int byte_count) {
            listener.bytesReceived(byte_count);
        }

        @Override
        public boolean isPriority() {
            return (is_priority);
        }
    };
    // save this mapping for later
    registrations.put(listener, core_listener);
    core_queue.registerQueueListener(core_listener);
}
Also used : MessageAdapter(com.biglybt.pifimpl.local.messaging.MessageAdapter) BTMessage(com.biglybt.core.peermanager.messaging.bittorrent.BTMessage) Message(com.biglybt.pif.messaging.Message) IncomingMessageQueue(com.biglybt.pif.network.IncomingMessageQueue) IncomingMessageQueueListener(com.biglybt.pif.network.IncomingMessageQueueListener) BTMessage(com.biglybt.core.peermanager.messaging.bittorrent.BTMessage)

Aggregations

BTMessage (com.biglybt.core.peermanager.messaging.bittorrent.BTMessage)1 Message (com.biglybt.pif.messaging.Message)1 IncomingMessageQueue (com.biglybt.pif.network.IncomingMessageQueue)1 IncomingMessageQueueListener (com.biglybt.pif.network.IncomingMessageQueueListener)1 MessageAdapter (com.biglybt.pifimpl.local.messaging.MessageAdapter)1