本文整理汇总了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);
}
}
}
示例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);
}
}
});
}
示例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);
}
});
}
示例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;
}
示例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();
}
});
}
示例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();
}
});
}
});
}
示例7: addCloseFutureListener
import org.apache.sshd.common.future.SshFutureListener; //导入依赖的package包/类
@Override
public void addCloseFutureListener(SshFutureListener<CloseFuture> listener) {
throw new RuntimeException("Not implemented");
}
示例8: removeCloseFutureListener
import org.apache.sshd.common.future.SshFutureListener; //导入依赖的package包/类
@Override
public void removeCloseFutureListener(SshFutureListener<CloseFuture> listener) {
throw new RuntimeException("Not implemented");
}