Examples of GenericMessageRegistration


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

          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

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

      final int  stream_crypto   = MessageManager.STREAM_ENCRYPTION_RC4_REQUIRED;
      final boolean  use_sts    = true;
      final int  block_crypto   = SESecurityManager.BLOCK_ENCRYPTION_AES;
     
      GenericMessageRegistration  reg =
        plugin_interface.getMessageManager().registerGenericMessageType(
          "GENTEST", "Gen test desc",
          stream_crypto,
          new GenericMessageHandler()
          {
            public boolean
            accept(
              GenericMessageConnection  connection )
           
              throws MessageException
            {
              System.out.println( "accept" );
             
              try{
                if ( use_sts ){
                 
                  connection = sec_man.getSTSConnection(
                      connection,
                      my_key,
                      new SEPublicKeyLocator()
                      {
                        public boolean
                        accept(
                          Object    context,
                          SEPublicKey  other_key )
                        {
                          System.out.println( "acceptKey" );
                         
                          return( true );
                        }
                      },
                      "test",
                      block_crypto );
                }
                   
                connection.addListener(
                  new GenericMessageConnectionListener()
                  {
                    public void
                    connected(
                      GenericMessageConnection  connection )
                    {
                    }
                   
                    public void
                    receive(
                      GenericMessageConnection  connection,
                      PooledByteBuffer      message )
                   
                      throws MessageException
                    {
                      System.out.println( "receive: " + message.toByteArray().length );
                     
                      PooledByteBuffer  reply =
                        plugin_interface.getUtilities().allocatePooledByteBuffer(
                            new byte[connection.getMaximumMessageSize()]);
                     
                      connection.send( reply );
                    }
                   
                    public void
                    failed(
                      GenericMessageConnection  connection,
                      Throwable           error )
                   
                      throws MessageException
                    {
                      System.out.println( "Responder connection error:" );

                      error.printStackTrace();
                   
                  });
               
              }catch( Throwable e ){
               
                connection.close();
               
                e.printStackTrace();
              }
             
              return( true );
            }
          });
     
      InetSocketAddress  tcp_target = new InetSocketAddress( "127.0.0.1",     6889 );
      InetSocketAddress  udp_target = new InetSocketAddress( "212.159.18.92",   6881 );
     
      GenericMessageEndpoint  endpoint = reg.createEndpoint( tcp_target );
     
      endpoint.addTCP( tcp_target );
      endpoint.addUDP( udp_target );
     
      while( true ){
       
        try{
          for (int i=0;i<1000;i++){
           
            System.out.println( "Test: initiating connection" );
           
            final AESemaphore  sem = new AESemaphore( "wait!" );
           
            GenericMessageConnection  con = reg.createConnection( endpoint );
           
            if ( use_sts ){
             
              con = sec_man.getSTSConnection(
                con, my_key,
View Full Code Here

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

  protected GenericMessageConnection
  outgoingConnection()
 
    throws BuddyPluginException
  {
    GenericMessageRegistration msg_registration = plugin.getMessageRegistration();

    if ( msg_registration == null ){
           
      throw( new BuddyPluginException( "Messaging system unavailable" ));
    }
   
    InetAddress ip = getIP();
   
    if ( ip == null ){
           
      throw( new BuddyPluginException( "Friend offline (no usable IP address)" ));
    }
   
    InetSocketAddress  tcp_target  = null;
    InetSocketAddress  udp_target  = null;
   
    int  tcp_port = getTCPPort();
   
    if ( tcp_port > 0 ){
     
      tcp_target = new InetSocketAddress( ip, tcp_port );
    }
   
    int  udp_port = getUDPPort();
   
    if ( udp_port > 0 ){
     
      udp_target = new InetSocketAddress( ip, udp_port );
    }

    InetSocketAddress  notional_target = tcp_target;
   
    if ( notional_target == null ){
   
      notional_target = udp_target;
    }
   
    if ( notional_target == null ){
           
      throw( new BuddyPluginException( "Friend offline (no usable protocols)" ));
    }
   
    GenericMessageEndpoint  endpoint = msg_registration.createEndpoint( notional_target );
   
    if ( tcp_target != null ){
   
      endpoint.addTCP( tcp_target );
    }
   
    if ( udp_target != null ){
   
      endpoint.addUDP( udp_target );
    }
       
    GenericMessageConnection  con = null;
   
    try{
      last_connect_attempt = SystemTime.getCurrentTime();
     
      con = msg_registration.createConnection( endpoint );
       
      plugin.addRateLimiters( con );
     
      String reason = "Friend: Outgoing connection establishment";
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.