当前位置: 首页>>代码示例>>Java>>正文


Java SshFutureListener类代码示例

本文整理汇总了Java中org.apache.sshd.common.future.SshFutureListener的典型用法代码示例。如果您正苦于以下问题:Java SshFutureListener类的具体用法?Java SshFutureListener怎么用?Java SshFutureListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SshFutureListener类属于org.apache.sshd.common.future包,在下文中一共展示了SshFutureListener类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeWithPendingDetection

import org.apache.sshd.common.future.SshFutureListener; //导入依赖的package包/类
private void writeWithPendingDetection(final Buffer msg, final boolean wasPending) {
    try {
        asyncIn.write(msg).addListener(new SshFutureListener<IoWriteFuture>() {
            @SuppressWarnings("synthetic-access")
            @Override
            public void operationComplete(IoWriteFuture future) {
                if (future.isWritten()) {
                    if (wasPending) {
                        pending.remove();
                    }
                    writePendingIfAny();
                } else {
                    Throwable t = future.getException();
                    log.warn("Failed to write message", t);
                }
            }
        });
    } catch (final WritePendingException e) {
        if (!wasPending) {
            queueRequest(msg);
        }
    }
}
 
开发者ID:termd,项目名称:termd,代码行数:24,代码来源:WindowAdjustTest.java

示例2: sessionCreated

import org.apache.sshd.common.future.SshFutureListener; //导入依赖的package包/类
@Override
public void sessionCreated(final IoSession session) throws Exception {
    final TcpipClientChannel channel;
    int localPort = ((InetSocketAddress) session.getLocalAddress()).getPort();
    if (localToRemote.containsKey(localPort)) {
        SshdSocketAddress remote = localToRemote.get(localPort);
        channel = new TcpipClientChannel(TcpipClientChannel.Type.Direct, session, remote);
    } else {
        channel = new TcpipClientChannel(TcpipClientChannel.Type.Forwarded, session, null);
    }
    session.setAttribute(TcpipClientChannel.class, channel);
    this.session.registerChannel(channel);
    channel.open().addListener(new SshFutureListener<OpenFuture>() {
        @Override
        public void operationComplete(OpenFuture future) {
            Throwable t = future.getException();
            if (t != null) {
                DefaultTcpipForwarder.this.session.unregisterChannel(channel);
                channel.close(false);
            }
        }
    });
}
 
开发者ID:cloudnautique,项目名称:cloud-cattle,代码行数:24,代码来源:DefaultTcpipForwarder.java

示例3: close

import org.apache.sshd.common.future.SshFutureListener; //导入依赖的package包/类
@Override
public void close() throws IOException {
    out.close(false).addListener(new SshFutureListener<CloseFuture>() {
        @SuppressWarnings("synthetic-access")
        @Override
        public void operationComplete(CloseFuture future) {
            callback.onExit(0);
        }
    });
}
 
开发者ID:termd,项目名称:termd,代码行数:11,代码来源:AsyncEchoShellFactory.java

示例4: data

import org.apache.sshd.common.future.SshFutureListener; //导入依赖的package包/类
@Override
public int data(final ChannelSession channel, byte[] buf, int start, int len) throws IOException {
    buffer.append(new String(buf, start, len));
    for (int i = 0; i < buffer.length(); i++) {
        if (buffer.charAt(i) == '\n') {
            final String s = buffer.substring(0, i + 1);
            final byte[] bytes = s.getBytes(StandardCharsets.UTF_8);
            out.write(new ByteArrayBuffer(bytes)).addListener(new SshFutureListener<IoWriteFuture>() {
                @Override
                public void operationComplete(IoWriteFuture future) {
                    Session session = channel.getSession();
                    if (future.isWritten()) {
                        try {
                            Window wLocal = channel.getLocalWindow();
                            wLocal.consumeAndCheck(bytes.length);
                        } catch (IOException e) {
                            session.exceptionCaught(e);
                        }
                    } else {
                        Throwable t = future.getException();
                        session.exceptionCaught(t);
                    }
                }
            });
            buffer = new StringBuilder(buffer.substring(i + 1));
            i = 0;
        }
    }
    return 0;
}
 
开发者ID:termd,项目名称:termd,代码行数:31,代码来源:AsyncEchoShellFactory.java

示例5: close

import org.apache.sshd.common.future.SshFutureListener; //导入依赖的package包/类
@Override
public CloseFuture close(boolean immediately) {
    return super.close(immediately).addListener(new SshFutureListener<CloseFuture>() {
        @Override
        public void operationComplete(CloseFuture sshFuture) {
            closeImmediately0();
        }
    });
}
 
开发者ID:cloudnautique,项目名称:cloud-cattle,代码行数:10,代码来源:TcpipServerChannel.java

示例6: close

import org.apache.sshd.common.future.SshFutureListener; //导入依赖的package包/类
@Override
public CloseFuture close(boolean immediately) {
    return super.close(immediately).addListener(new SshFutureListener<CloseFuture>() {
        @Override
        public void operationComplete(CloseFuture sshFuture) {
            executor.execute(new Runnable() {
                @Override
                public void run() {
                    getConnector().dispose();
                }
            });
        }
    });
}
 
开发者ID:cloudnautique,项目名称:cloud-cattle,代码行数:15,代码来源:EofClosingTcpipServerChannel.java

示例7: addCloseFutureListener

import org.apache.sshd.common.future.SshFutureListener; //导入依赖的package包/类
@Override
public void addCloseFutureListener(SshFutureListener<CloseFuture> listener) {
    throw new RuntimeException("Not implemented");

}
 
开发者ID:NLeSC,项目名称:Xenon,代码行数:6,代码来源:MockClientSession.java

示例8: removeCloseFutureListener

import org.apache.sshd.common.future.SshFutureListener; //导入依赖的package包/类
@Override
public void removeCloseFutureListener(SshFutureListener<CloseFuture> listener) {
    throw new RuntimeException("Not implemented");

}
 
开发者ID:NLeSC,项目名称:Xenon,代码行数:6,代码来源:MockClientSession.java


注:本文中的org.apache.sshd.common.future.SshFutureListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。