org.apache.sshd.common.future.SshFutureListener Java Examples
The following examples show how to use
org.apache.sshd.common.future.SshFutureListener.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WindowAdjustTest.java From termd with Apache License 2.0 | 6 votes |
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); } } }
Example #2
Source File: WindowAdjustTest.java From termd with Apache License 2.0 | 6 votes |
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); } } }
Example #3
Source File: TtyCommand.java From termd with Apache License 2.0 | 5 votes |
private void close(final int exit) throws IOException { ioOut.close(false).addListener(new SshFutureListener<CloseFuture>() { @Override public void operationComplete(CloseFuture future) { exitCallback.onExit(exit); if (closed.compareAndSet(false, true)) { if (closeHandler != null) { closeHandler.accept(null); } else { // This happen : report it to the SSHD project } } } }); }
Example #4
Source File: AsyncEchoShellFactory.java From termd with Apache License 2.0 | 5 votes |
@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); } }); }
Example #5
Source File: AsyncEchoShellFactory.java From termd with Apache License 2.0 | 5 votes |
@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; }
Example #6
Source File: AsyncEchoShellFactory.java From termd with Apache License 2.0 | 5 votes |
@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); } }); }
Example #7
Source File: AsyncEchoShellFactory.java From termd with Apache License 2.0 | 5 votes |
@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; }
Example #8
Source File: MockClientSession.java From xenon with Apache License 2.0 | 4 votes |
@Override public void addCloseFutureListener(SshFutureListener<CloseFuture> listener) { throw new RuntimeException("Not implemented"); }
Example #9
Source File: MockClientSession.java From xenon with Apache License 2.0 | 4 votes |
@Override public void removeCloseFutureListener(SshFutureListener<CloseFuture> listener) { throw new RuntimeException("Not implemented"); }