public ScreenCaster(Vertx vertx, Robot robot, Term term) { this.vertx = vertx; this.robot = robot; this.term = term; term.stdinHandler(keys -> { // Ctrl-C or Ctrl-D if (keys.contains("\u0003") || keys.contains("\u0004")) { interrupted = true; } }); }
public io.vertx.rxjava.ext.shell.term.Term stdinHandler(Handler<String> handler) { delegate.stdinHandler(handler); return this; }
public io.vertx.rxjava.ext.shell.term.Term stdinHandler(Handler<String> handler) { delegate.stdinHandler(handler); return this; }
@Test public void testRead(TestContext context) throws Exception { Async async = context.async(); termHandler = term -> { term.stdinHandler(s -> { context.assertEquals("hello", s); async.complete(); }); }; startShell(); Session session = createSession("paulo", "secret", false); session.connect(); Channel channel = session.openChannel("shell"); channel.connect(); OutputStream out = channel.getOutputStream(); out.write("hello".getBytes()); out.flush(); channel.disconnect(); session.disconnect(); }
@Test public void testRead(TestContext context) throws IOException { Async async = context.async(); startTelnet(context, term -> { term.stdinHandler(s -> { context.assertEquals("hello_from_client", s); async.complete(); }); }); client.connect("localhost", server.actualPort()); Writer writer = new OutputStreamWriter(client.getOutputStream()); writer.write("hello_from_client"); writer.flush(); }
@Test public void testServerRead(TestContext context) { Async async = context.async(); server = createServer(context, new HttpTermOptions().setPort(8080)); server.termHandler(term -> { term.stdinHandler(buf -> { context.assertEquals("hello_from_client", buf); async.complete(); }); }); server.listen(context.asyncAssertSuccess(server -> { HttpClient client = vertx.createHttpClient(); client.websocket(8080, "localhost", basePath + "/shell/websocket", ws -> { ws.writeFinalTextFrame(new JsonObject().put("action", "read").put("data", "hello_from_client").encode()); }, context::fail); })); }