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);
}
Aggregations