Package org.apache.mina.common

Examples of org.apache.mina.common.IoConnector.connect()


                System.out.println( Thread.currentThread().getName() + ": " + message );
               
                if ( "open new".equals( message ) ) {
                    System.out.println( "opening c2 from " + Thread.currentThread().getName() );

                    ConnectFuture c2Future = connector.connect( address, new IoHandlerAdapter() {
                        public void sessionOpened( IoSession session ) throws Exception {
                            session.write( "re-use c1" );
                        }

                        public void messageReceived( IoSession session, Object message ) throws Exception {
View Full Code Here


    
        IoConnector connector = new VmPipeConnector();
        IoSession[] sessions = new IoSession[ 5 ];
        for( int i = 0; i < sessions.length; i++ )
        {
            ConnectFuture future = connector.connect( addr, new IoHandlerAdapter() );
            future.join();
            sessions[ i ] = future.getSession();
            Assert.assertTrue( sessions[ i ].isConnected() );
        }
       
View Full Code Here

    protected ConnectFuture connect( int port, IoHandler handler )
            throws Exception
    {
        IoConnector connector = new VmPipeConnector();
        SocketAddress addr = new VmPipeAddress( port );
        return connector.connect( addr, handler );
    }

    protected SocketAddress createServerSocketAddress( int port )
    {
        return new VmPipeAddress( port );
View Full Code Here

    protected ConnectFuture connect( int port, IoHandler handler )
            throws Exception
    {
        IoConnector connector = new DatagramConnector();
        SocketAddress addr = new InetSocketAddress( "localhost", port );
        return connector.connect( addr, handler );
    }

    protected SocketAddress createServerSocketAddress( int port )
    {
        return new InetSocketAddress( port );
View Full Code Here

    
        IoConnector connector = new SocketConnector();
        IoSession[] sessions = new IoSession[ 5 ];
        for( int i = 0; i < sessions.length; i++ )
        {
            ConnectFuture future = connector.connect( new InetSocketAddress( "localhost", port ), new IoHandlerAdapter() );
            future.join();
            sessions[ i ] = future.getSession();
            Assert.assertTrue( sessions[ i ].isConnected() );
        }
       
View Full Code Here

    protected ConnectFuture connect( int port, IoHandler handler )
            throws Exception
    {
        IoConnector connector = new SocketConnector();
        SocketAddress addr = new InetSocketAddress( "localhost", port );
        return connector.connect( addr, handler );
    }

    protected SocketAddress createServerSocketAddress( int port )
    {
        return new InetSocketAddress( port );
View Full Code Here

        _logger.info("Attempting connection to " + address);

        //Old mina style
//        ioConnector.setHandler(new WriterHandler());
//        ConnectFuture future = ioConnector.connect(address);
        ConnectFuture future = ioConnector.connect(address, new WriterHandler());
        // wait for connection to complete
        future.join();
        _logger.info("Connection completed");
        // we call getSession which throws an IOException if there has been an error connecting
        _session = future.getSession();
View Full Code Here

            address = new InetSocketAddress(brokerDetail.getHost(), brokerDetail.getPort());
            _logger.info("Attempting connection to " + address);
        }


        ConnectFuture future = ioConnector.connect(address, protocolHandler);

        // wait for connection to complete
        if (future.join(brokerDetail.getTimeout()))
        {
            // we call getSession which throws an IOException if there has been an error connecting
View Full Code Here

            @Override
            public void messageReceived(IoSession ioSession, Object object) throws Exception {
                super.messageReceived(ioSession, object);    /** TODO */
            }
        };
        ConnectFuture future = connector.connect(address, ioHandler, endpoint.getConfig());
        future.join();
        session = future.getSession();
    }

    @Override
View Full Code Here

        IoSession session;
        for( ;; )
        {
            try
            {
                ConnectFuture future = connector.connect(
                        new InetSocketAddress( HOSTNAME, PORT ),
                        new ClientSessionHandler( USE_CUSTOM_CODEC, values ) );
               
                future.join();
                session = future.getSession();
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.