Package org.apache.mina.common

Examples of org.apache.mina.common.ConnectFuture


        connector.connect( address, connectorHandler ).addListener(
                new IoFutureListener()
        {
            public void operationComplete( IoFuture f )
            {
                ConnectFuture future = ( ConnectFuture ) f;
                try
                {
                    future.getSession().setAttachment( session );
                    session.setAttachment( future.getSession() );
                    future.getSession().setTrafficMask( TrafficMask.ALL );
                }
                catch( RuntimeIOException e )
                {
                    // Connect failed
                    session.close();
View Full Code Here


    protected abstract ConnectFuture connect( int port, IoHandler handler) throws Exception;
    protected abstract SocketAddress createServerSocketAddress( int port );
   
    public void testSuspendResumeReadWrite() throws Exception
    {
        ConnectFuture future = connect( port, new ClientIoHandler() );
        future.join();
        IoSession session = future.getSession();
       
        Object lock = session.getAttribute( "lock" );
        synchronized( lock )
        {
       
View Full Code Here

        // Set up server
        acceptor.bind( address, new TennisPlayer() );

        // Connect to the server.
        VmPipeConnector connector = new VmPipeConnector();
        ConnectFuture future = connector.connect( address,
                                                  new TennisPlayer() );
        future.join();
        IoSession session = future.getSession();

        // Send the first ping message
        session.write( new TennisBall( 10 ) );

        // Wait until the match ends.
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();
                break;
            }
            catch( RuntimeIOException e )
            {
                System.err.println( "Failed to connect." );
View Full Code Here

            if( ch.connect( address ) )
            {
                SocketSessionImpl session = newSession( ch, handler, config );
                success = true;
                ConnectFuture future = new ConnectFuture();
                future.setSession( session );
                return future;
            }
           
            success = true;
        }
View Full Code Here

        {
            return ConnectFuture.newFailedFuture(
                    new IOException( "Endpoint unavailable: " + address ) );
        }

        ConnectFuture future = new ConnectFuture();
        try
        {
            VmPipeSessionImpl session =
                new VmPipeSessionImpl(
                        this,
                        new Object(), // lock
                        AnonymousSocketAddress.INSTANCE,
                        handler,
                        config.getFilterChainBuilder(),
                        entry );
            future.setSession( session );
        }
        catch( IOException e )
        {
            future.setException( e );
        }
        return future;
    }
View Full Code Here

    protected abstract ConnectFuture connect( int port, IoHandler handler) throws Exception;
    protected abstract SocketAddress createServerSocketAddress( int port );
   
    public void testSuspendResumeReadWrite() throws Exception
    {
        ConnectFuture future = connect( port, new ClientIoHandler() );
        future.join();
        IoSession session = future.getSession();
       
        Object lock = session.getAttribute( "lock" );
        synchronized( lock )
        {
       
View Full Code Here

        // Set up server
        acceptor.bind(address, new TennisPlayer());

        // Connect to the server.
        VmPipeConnector connector = new VmPipeConnector();
        ConnectFuture future = connector.connect(address, new TennisPlayer());
        future.join();
        IoSession session = future.getSession();

        // Send the first ping message
        session.write(new TennisBall(10));

        // Wait until the match ends.
View Full Code Here

                SSLFilter sslFilter = new SSLFilter(sslContext);
                sslFilter.setUseClientMode(true);
                config.getFilterChain().addLast("sslFilter", sslFilter);
            }

            ConnectFuture future1 = connector.connect(address, handler, config);
            future1.join();
            if (!future1.isConnected()) {
                return false;
            }
            session = future1.getSession();
            session.write("LOGIN " + name);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
View Full Code Here

        MockHandler connectorHandler = new MockHandler();

        acceptor.bind(new InetSocketAddress(port), acceptorHandler, config);

        try {
            ConnectFuture future = connector.connect(new InetSocketAddress(
                    "localhost", port), connectorHandler, config);
            future.join();

            // Write whatever to trigger the acceptor.
            future.getSession().write(ByteBuffer.allocate(1)).join();

            // Wait until the connection is closed.
            future.getSession().getCloseFuture().join(3000);
            Assert.assertTrue(future.getSession().getCloseFuture().isClosed());
            acceptorHandler.session.getCloseFuture().join(3000);
            Assert.assertTrue(acceptorHandler.session.getCloseFuture()
                    .isClosed());

            Thread.sleep(1000);
View Full Code Here

TOP

Related Classes of org.apache.mina.common.ConnectFuture

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.