FileDocCategorySizeDatePackage
IncomingMessageQueueImpl.javaAPI DocAzureus 3.0.3.43874Fri Jun 16 10:25:16 BST 2006org.gudy.azureus2.pluginsimpl.local.network

IncomingMessageQueueImpl

public class IncomingMessageQueueImpl extends Object implements IncomingMessageQueue

Fields Summary
private final com.aelitis.azureus.core.networkmanager.IncomingMessageQueue
core_queue
private final HashMap
registrations
Constructors Summary
protected IncomingMessageQueueImpl(com.aelitis.azureus.core.networkmanager.IncomingMessageQueue core_queue)

  
  
       
    this.core_queue = core_queue;
  
Methods Summary
public voidderegisterListener(IncomingMessageQueueListener listener)

    //retrieve saved mapping
    com.aelitis.azureus.core.networkmanager.IncomingMessageQueue.MessageQueueListener core_listener =
      (com.aelitis.azureus.core.networkmanager.IncomingMessageQueue.MessageQueueListener)registrations.remove( listener );
    
    if( core_listener != null ) {
      core_queue.cancelQueueListener( core_listener );
    }
  
public intgetPercentDoneOfCurrentMessage()

    return core_queue.getPercentDoneOfCurrentMessage();
  
public voidnotifyOfExternalReceive(Message message)

    if( message instanceof MessageAdapter ) {
      //the message must have been originally created by core and wrapped
      //so just use original core message...i.e. unwrap out of MessageAdapter
      core_queue.notifyOfExternallyReceivedMessage( ((MessageAdapter)message).getCoreMessage() );
      return;
    }
    
    //message originally created by plugin
    core_queue.notifyOfExternallyReceivedMessage( new MessageAdapter( message ) );
  
public voidregisterListener(IncomingMessageQueueListener listener)

    com.aelitis.azureus.core.networkmanager.IncomingMessageQueue.MessageQueueListener core_listener = 
      new com.aelitis.azureus.core.networkmanager.IncomingMessageQueue.MessageQueueListener() {
        public boolean messageReceived( com.aelitis.azureus.core.peermanager.messaging.Message message ) {
          if( message instanceof MessageAdapter ) {
            //the message must have been originally decoded by plugin decoder
            //so just use original plugin message...i.e. unwrap out of MessageAdapter
            return listener.messageReceived( ((MessageAdapter)message).getPluginMessage() );
          }
          
          //message originally decoded by core
          return listener.messageReceived( new MessageAdapter( message ) );
        }
      
        public void protocolBytesReceived( int byte_count ) {  listener.bytesReceived( byte_count );  }

        public void dataBytesReceived( int byte_count ) {  listener.bytesReceived( byte_count );  }
    };
    
    registrations.put( listener, core_listener );  //save this mapping for later
    
    core_queue.registerQueueListener( core_listener );