Package org.apache.mina.core.future

Examples of org.apache.mina.core.future.ConnectFuture.awaitUninterruptibly()


      log.debug("About to connect to the server... PORT: "+ClientConnectionBean.host);
     
      ConnectFuture connFuture = connector.connect(new InetSocketAddress(
                          ClientConnectionBean.host, port));
      log.debug("About to wait.");
      connFuture.awaitUninterruptibly();
      log.debug("Adding a future listener.");
      connFuture.addListener(new IoFutureListener<ConnectFuture>() {
        public void operationComplete(ConnectFuture future) {
          if (future.isConnected()) {
            log.debug("...connected");
View Full Code Here


        InetSocketAddress addr = new InetSocketAddress("localhost",
                AvailablePortFinder.getNextAvailable(20000));

        acceptor.bind(addr);
        ConnectFuture future = connector.connect(addr);
        future.awaitUninterruptibly();
        IoSession session = future.getSession();
        WriteFuture wf = session.write(IoBuffer.allocate(1))
                .awaitUninterruptibly();
        assertNotNull(wf.getException());
View Full Code Here

    connector.getFilterChain().addLast( "logger", new LoggingFilter() );
    connector.getFilterChain().addLast( "codec", new ProtocolCodecFilter( new TextLineCodecFactory( Charset.forName( "UTF-8" ))));

    // Start communication.
    ConnectFuture cf = connector.connect(new InetSocketAddress("localhost", 9123));
    cf.awaitUninterruptibly();

    IoSession session = cf.getSession();

    // send a message
    session.write("Hello World!\r");
View Full Code Here

        // And create the connection future
        ConnectFuture connectionFuture = connector.connect( address );

        // Wait until it's established
        connectionFuture.awaitUninterruptibly();

        boolean isConnected = connectionFuture.isConnected();

        if ( !isConnected )
        {
View Full Code Here

        // And create the connection future
        ConnectFuture connectionFuture = connector.connect( address );

        // Wait until it's established
        connectionFuture.awaitUninterruptibly();

        boolean isConnected = connectionFuture.isConnected();

        if ( !isConnected )
        {
View Full Code Here

            connector.getSessionConfig().setAll(connectorConfig);
        }

        connector.setHandler(new ResponseHandler());
        ConnectFuture future = connector.connect(address);
        future.awaitUninterruptibly();
        session = future.getSession();
    }

    // Implementation methods
    //-------------------------------------------------------------------------
View Full Code Here

        }
    }

    private SocketAddress connectAndWrite(NioSocketConnector connector, int clientNr) {
        ConnectFuture connectFuture = connector.connect(new InetSocketAddress("localhost", port));
        connectFuture.awaitUninterruptibly(TIMEOUT);
        IoBuffer message = IoBuffer.allocate(4).putInt(clientNr).flip();
        IoSession session = connectFuture.getSession();
        session.write(message).awaitUninterruptibly(TIMEOUT);
        return session.getLocalAddress();
    }
View Full Code Here

        return (session != null && session.isConnected());
    }

    public void connect() {
        ConnectFuture connectFuture = connector.connect(new InetSocketAddress(host, port));
        connectFuture.awaitUninterruptibly(CONNECT_TIMEOUT);
        try {
            session = connectFuture.getSession();
        }
        catch (RuntimeIoException e) {
            imageListener.onException(e);
View Full Code Here

        IoSession session;
        for (;;) {
            try {
                ConnectFuture future = connector.connect(new InetSocketAddress(
                        HOSTNAME, PORT));
                future.awaitUninterruptibly();
                session = future.getSession();
                break;
            } catch (RuntimeIoException e) {
                System.err.println("Failed to connect.");
                e.printStackTrace();
View Full Code Here

                connector.getFilterChain().addLast("sslFilter", sslFilter);
            }

            connector.setHandler(handler);
            ConnectFuture future1 = connector.connect(address);
            future1.awaitUninterruptibly();
            if (!future1.isConnected()) {
                return false;
            }
            session = future1.getSession();
            login();
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.