/** * Set a handler that will be called when the terminal is closed. * @param handler the handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.shell.term.Term closeHandler(Handler<Void> handler) { delegate.closeHandler(handler); return this; }
/** * Set a handler that will be called when the terminal is closed. * @param handler the handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.shell.term.Term closeHandler(Handler<Void> handler) { delegate.closeHandler(handler); return this; }
private void testClose(TestContext context, Consumer<Term> closer) throws Exception { Async async = context.async(); termHandler = term -> { term.closeHandler(v -> { async.complete(); }); closer.accept(term); }; startShell(); Session session = createSession("paulo", "secret", false); session.connect(); Channel channel = session.openChannel("shell"); channel.connect(); while (channel.isClosed()) { Thread.sleep(10); } }
public ShellImpl init() { term.interruptHandler(key -> jobController().foregroundJob().interrupt()); term.suspendHandler(key -> { term.echo(Helper.fromCodePoints(new int[]{key, '\n'})); Job job = jobController.foregroundJob(); term.echo(statusLine(job, ExecStatus.STOPPED) + "\n"); job.suspend(); return true; }); term.closeHandler(v -> jobController.close(ar -> closedFuture.complete() ) ); if (welcome != null && welcome.length() > 0) { term.write(welcome); } return this; }
@Test public void testCloseHandler(TestContext context) throws Exception { Async async = context.async(); termHandler = term -> { term.closeHandler(v -> { async.complete(); }); }; startShell(); Session session = createSession("paulo", "secret", false); session.connect(); Channel channel = session.openChannel("shell"); channel.connect(); channel.disconnect(); session.disconnect(); }
private void testClose(TestContext context, Consumer<Term> closer) throws Exception { Async async1 = context.async(); Async async2 = context.async(); startTelnet(context, term -> { term.closeHandler(v -> { async2.complete(); }); closer.accept(term); async1.complete(); }); client.connect("localhost", server.actualPort()); async1.await(4000); OutputStream out = client.getOutputStream(); long now = System.currentTimeMillis(); while (true) { context.assertTrue(System.currentTimeMillis() - now < 10000); try { out.write(4); out.flush(); } catch (IOException ignore) { break; } Thread.sleep(10); } }
@Test public void testCloseHandler(TestContext context) throws IOException { Async async1 = context.async(); Async async2 = context.async(); startTelnet(context, term -> { term.closeHandler(v -> { async2.complete(); }); async1.complete(); }); client.connect("localhost", server.actualPort()); async1.awaitSuccess(4000); client.disconnect(); }