Examples of IoConnectFuture


Examples of org.apache.sshd.common.io.IoConnectFuture

                close(true);
            }
        };
        connector = getSession().getFactoryManager().getIoServiceFactory()
                .createConnector(handler);
        IoConnectFuture future = connector.connect(address.toInetSocketAddress());
        future.addListener(new SshFutureListener<IoConnectFuture>() {
            public void operationComplete(IoConnectFuture future) {
                if (future.isConnected()) {
                    ioSession = future.getSession();
                    f.setOpened();
                } else if (future.getException() != null) {
                    closeImmediately0();
                    if (future.getException() instanceof ConnectException) {
                        f.setException(new OpenChannelException(
                            SshConstants.SSH_OPEN_CONNECT_FAILED,
                            future.getException().getMessage(),
                            future.getException()));
                    } else {
                        f.setException(future.getException());
                    }
                }
            }
        });
        return f;
View Full Code Here

Examples of org.apache.sshd.common.io.IoConnectFuture

        super(manager, handler, group);
    }

    public IoConnectFuture connect(SocketAddress address) {
        logger.debug("Connecting to {}", address);
        final IoConnectFuture future = new DefaultIoConnectFuture(null);
        try {
            final AsynchronousSocketChannel socket = AsynchronousSocketChannel.open(group);
            socket.connect(address, null, new Nio2CompletionHandler<Void, Object>() {
                protected void onCompleted(Void result, Object attachment) {
                    try {
                        Nio2Session session = new Nio2Session(Nio2Connector.this, handler, socket);
                        handler.sessionCreated(session);
                        sessions.put(session.getId(), session);
                        future.setSession(session);
                        session.startReading();
                    } catch (Throwable e) {
                        try {
                            socket.close();
                        } catch (IOException t) {
                            // Ignore
                        }
                        future.setException(e);
                    }
                }
                protected void onFailed(final Throwable exc, final Object attachment) {
                    future.setException(exc);
                }
            });
        } catch (IOException exc) {
            future.setException(exc);
        }
        return future;
    }
View Full Code Here

Examples of org.apache.sshd.common.io.IoConnectFuture

            public void setException(Throwable exception) {
                setValue(exception);
            }
        }
        final IoConnectFuture future = new Future(null);
        getConnector().connect(address).addListener(new IoFutureListener<ConnectFuture>() {
            public void operationComplete(ConnectFuture cf) {
                if (cf.getException() != null) {
                    future.setException(cf.getException());
                } else if (cf.isCanceled()) {
                    future.cancel();
                } else {
                    future.setSession(getSession(cf.getSession()));
                }
            }
        });
        return future;
    }
View Full Code Here

Examples of org.apache.sshd.common.io.IoConnectFuture

                close(true);
            }
        };
        connector = getSession().getFactoryManager().getIoServiceFactory()
                .createConnector(handler);
        IoConnectFuture future = connector.connect(address.toInetSocketAddress());
        future.addListener(new SshFutureListener<IoConnectFuture>() {
            public void operationComplete(IoConnectFuture future) {
                if (future.isConnected()) {
                    ioSession = future.getSession();
                    f.setOpened();
                } else if (future.getException() != null) {
                    closeImmediately0();
                    if (future.getException() instanceof ConnectException) {
                        f.setException(new OpenChannelException(
                            SshConstants.SSH_OPEN_CONNECT_FAILED,
                            future.getException().getMessage(),
                            future.getException()));
                    } else {
                        f.setException(future.getException());
                    }
                }
            }
        });
        return f;
View Full Code Here

Examples of org.apache.sshd.common.io.IoConnectFuture

        super(manager, handler, group);
    }

    public IoConnectFuture connect(SocketAddress address) {
        logger.debug("Connecting to {}", address);
        final IoConnectFuture future = new DefaultIoConnectFuture(null);
        try {
            final AsynchronousSocketChannel socket = AsynchronousSocketChannel.open(group);
            socket.connect(address, null, new CompletionHandler<Void, Object>() {
                public void completed(Void result, Object attachment) {
                    try {
                        Nio2Session session = new Nio2Session(Nio2Connector.this, handler, socket);
                        handler.sessionCreated(session);
                        sessions.put(session.getId(), session);
                        future.setSession(session);
                        session.startReading();
                    } catch (Throwable e) {
                        try {
                            socket.close();
                        } catch (IOException t) {
                            // Ignore
                        }
                        future.setException(e);
                    }
                }
                public void failed(Throwable exc, Object attachment) {
                    future.setException(exc);
                }
            });
        } catch (IOException exc) {
            future.setException(exc);
        }
        return future;
    }
View Full Code Here

Examples of org.apache.sshd.common.io.IoConnectFuture

                close(true);
            }
        };
        connector = getSession().getFactoryManager().getIoServiceFactory()
                .createConnector(getSession().getFactoryManager(), handler);
        IoConnectFuture future = connector.connect(address.toInetSocketAddress());
        future.addListener(new SshFutureListener<IoConnectFuture>() {
            public void operationComplete(IoConnectFuture future) {
                if (future.isConnected()) {
                    ioSession = future.getSession();
                    f.setOpened();
                } else if (future.getException() != null) {
                    closeImmediately0();
                    if (future.getException() instanceof ConnectException) {
                        f.setException(new OpenChannelException(
                            SshConstants.SSH_OPEN_CONNECT_FAILED,
                            future.getException().getMessage(),
                            future.getException()));
                    } else {
                        f.setException(future.getException());
                    }
                }
            }
        });
        return f;
View Full Code Here

Examples of org.apache.sshd.common.io.IoConnectFuture

        super(manager, handler);
    }

    public IoConnectFuture connect(SocketAddress address) {
        logger.debug("Connecting to {}", address);
        final IoConnectFuture future = new DefaultIoConnectFuture(null);
        try {
            final AsynchronousSocketChannel socket = AsynchronousSocketChannel.open(group);
            socket.connect(address, null, new CompletionHandler<Void, Object>() {
                public void completed(Void result, Object attachment) {
                    try {
                        Nio2Session session = new Nio2Session(Nio2Connector.this, handler, socket);
                        handler.sessionCreated(session);
                        sessions.put(session.getId(), session);
                        future.setSession(session);
                        session.startReading();
                    } catch (Throwable e) {
                        try {
                            socket.close();
                        } catch (IOException t) {
                            // Ignore
                        }
                        future.setException(e);
                    }
                }
                public void failed(Throwable exc, Object attachment) {
                    future.setException(exc);
                }
            });
        } catch (IOException exc) {
            future.setException(exc);
        }
        return future;
    }
View Full Code Here

Examples of org.apache.sshd.common.io.IoConnectFuture

            public void setException(Throwable exception) {
                setValue(exception);
            }
        }
        final IoConnectFuture future = new Future(null);
        getConnector().connect(address).addListener(new IoFutureListener<ConnectFuture>() {
            public void operationComplete(ConnectFuture cf) {
                if (cf.getException() != null) {
                    future.setException(cf.getException());
                } else if (cf.isCanceled()) {
                    future.cancel();
                } else {
                    future.setSession(getSession(cf.getSession()));
                }
            }
        });
        return future;
    }
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.