Package org.gudy.azureus2.plugins.messaging.generic

Examples of org.gudy.azureus2.plugins.messaging.generic.GenericMessageHandler


  public MessageStreamEncoderAdapter( MessageStreamEncoder plug_encoder ) {
    this.plug_encoder = plug_encoder;
  }
 
  public com.aelitis.azureus.core.networkmanager.RawMessage[] encodeMessage( com.aelitis.azureus.core.peermanager.messaging.Message message ) {
    Message plug_msg;
   
    if( message instanceof MessageAdapter ) {  //original message created by plugin, unwrap
      plug_msg = ((MessageAdapter)message).getPluginMessage();
    }
    else {
View Full Code Here


 
    throws MessageException
  {
    if ( incoming ){
     
      throw( new MessageException( "Already connected" ));
    }
   
    if ( connecting ){
     
      throw( new MessageException( "Connect already performed" ));
    }
   
    connecting  = true;
   
    if ( closed ){
     
      throw( new MessageException( "Connection has been closed" ));
    }
   
    InetSocketAddress  tcp_ep = endpoint.getTCP();
       
    if ( tcp_ep != null ){
     
      connectTCP( initial_data, tcp_ep );
     
    }else{
     
      InetSocketAddress  udp_ep = endpoint.getUDP();

      if ( udp_ep != null ){
       
        connectUDP( initial_data, udp_ep, false );
       
      }else{
       
        throw( new MessageException( "No protocols availabld" ));
      }
    }
  }
View Full Code Here

                delegate.close();
               
              }catch( Throwable e ){
              }
             
              reportFailed( new MessageException( "Connection has been closed" ));

            }else{
             
              reportConnected();
            }
View Full Code Here

              final InetSocketAddress  target,
              Map            reply )
            {
              if ( closed ){
                             
                reportFailed( new MessageException( "Connection has been closed" ));

              }else{
               
                connect_method_count++;

                if ( TEST_TUNNEL ){
                 
                  initial_data.rewind();
                 
                  connectTunnel( initial_data, gen_udp, rendezvous, target );
                 
                }else{
               
                  udp_delegate.connect(
                      initial_data,
                      new GenericMessageConnectionAdapter.ConnectionListener()
                      {
                        private boolean  connected;
                       
                        public void
                        connectSuccess()
                        {
                          connected  = true;
                         
                          setDelegate( udp_delegate );
                         
                          if ( closed ){
                           
                            try{
                              delegate.close();
                             
                            }catch( Throwable e ){                         
                            }
                           
                            reportFailed( new MessageException( "Connection has been closed" ));
                           
                          }else{
                           
                            reportConnected();
                          }                       
                        }
                       
                        public void
                        connectFailure(
                          Throwable failure_msg )
                        {
                          if ( connected ){
                           
                            reportFailed( failure_msg );
                           
                          }else{
                           
                            initial_data.rewind();
 
                            connectTunnel( initial_data, gen_udp, rendezvous, target );
                          }
                        }
                      });
                }
              }
            }
           
            public void
            failed(
              int      failure_type )
            {
              reportFailed( new MessageException( "UDP connection attempt failed - NAT traversal failed (" + NATTraversalObserver.FT_STRINGS[ failure_type ] + ")"));
            }
           
            public void
            failed(
              Throwable   cause )
            {
              reportFailed( cause );
            }
           
            public void
            disabled()
            {
              reportFailed( new MessageException( "UDP connection attempt failed as DDB is disabled" ));
            }
          });
    }else{
 
      udp_delegate.connect(
          initial_data,
          new GenericMessageConnectionAdapter.ConnectionListener()
          {
            private boolean  connected;
           
            public void
            connectSuccess()
            {
              connected  = true;
             
              setDelegate( udp_delegate );
             
              if ( closed ){
               
                try{
                  delegate.close();
                 
                }catch( Throwable e ){ 
                }
               
                reportFailed( new MessageException( "Connection has been closed" ));

              }else{
               
                reportConnected();
              }
View Full Code Here

               
              }catch( Throwable e ){
               
              }
             
              reportFailed( new MessageException( "Connection has been closed" ));

            }else{
             
              reportConnected();
            }
View Full Code Here

  {
    int  size = ((PooledByteBufferImpl)message).getBuffer().remaining( DirectByteBuffer.SS_EXTERNAL );
   
    if ( size > getMaximumMessageSize()){
     
      throw( new MessageException( "Message is too large: supplied is " + size + ", maximum is " + getMaximumMessageSize()));
    }
   
    delegate.send( message );
  }
View Full Code Here

      GenericMessageEndpointImpl  endpoint = new GenericMessageEndpointImpl( originator );
     
      endpoint.addUDP( originator );
         
      GenericMessageHandler  handler = message_manager.getHandler( msg_id );
     
      if ( handler == null ){
       
        Debug.out( "No message handler registered for '" + msg_id + "'" );
       
        return( null );
      }
     
      try{
        Long  con_id;

        synchronized( remote_connections ){
         
          if ( remote_connections.size() >= MAX_REMOTE_CONNECTIONS ){
           
            Debug.out( "Maximum remote connections exceeded - request from " + originator + " denied [" + getRemoteConnectionStatus() + "]" );
           
            return( null );
          }
         
          int  num_from_this_ip = 0;
                 
          Iterator  it = remote_connections.values().iterator();
         
          while( it.hasNext()){
           
            GenericMessageConnectionIndirect con = (GenericMessageConnectionIndirect)it.next();
           
            if ( con.getEndpoint().getNotionalAddress().getAddress().equals( originator.getAddress())){
             
              num_from_this_ip++;
            }
          }
         
          if ( num_from_this_ip >= MAX_REMOTE_CONNECTIONS_PER_IP ){
           
            Debug.out( "Maximum remote connections per-ip exceeded - request from " + originator + " denied [" + getRemoteConnectionStatus() + "]" );
           
            return( null );

          }
          con_id = new Long( connection_id_next++ );
        }
       
        GenericMessageConnectionIndirect indirect_connection =
          new GenericMessageConnectionIndirect(
              message_manager, msg_id, msg_desc, endpoint, con_id.longValue());

        GenericMessageConnectionImpl new_connection = new GenericMessageConnectionImpl( message_manager, indirect_connection );

        if ( handler.accept( new_connection )){
         
          new_connection.accepted();
 
          synchronized( remote_connections ){
                       
View Full Code Here

     
      GenericMessageRegistration  reg =
        plugin_interface.getMessageManager().registerGenericMessageType(
          "GENTEST", "Gen test desc",
          stream_crypto,
          new GenericMessageHandler()
          {
            public boolean
            accept(
              GenericMessageConnection  connection )
           
View Full Code Here

     
      msg_registration =
        plugin_interface.getMessageManager().registerGenericMessageType(
          "AZBUDDY", "Buddy message handler",
          STREAM_CRYPTO,
          new GenericMessageHandler()
          {
            public boolean
            accept(
              GenericMessageConnection  connection )
           
View Full Code Here

          public MessageStreamEncoder createEncoder() {  return new GenericMessageEncoder();}
          public MessageStreamDecoder createDecoder() {  return new GenericMessageDecoder(type, description);}
        });
   
  return(
    new GenericMessageRegistration()
    {
      public GenericMessageEndpoint
      createEndpoint(
        InetSocketAddress  notional_target )
      {
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.plugins.messaging.generic.GenericMessageHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.