public void handle() { if (term.width() > 0 && term.height() > 0) { broadcast(); } else { term.resizehandler(v -> { broadcast(); }); } }
public io.vertx.rxjava.ext.shell.term.Term resizehandler(Handler<Void> handler) { delegate.resizehandler(handler); return this; }
public io.vertx.rxjava.ext.shell.term.Term resizehandler(Handler<Void> handler) { delegate.resizehandler(handler); return this; }
@Test public void testResizeHandler(TestContext context) throws Exception { Async async = context.async(); termHandler = term -> { term.resizehandler(v -> { context.assertEquals(20, term.width()); context.assertEquals(10, term.height()); async.complete(); }); }; startShell(); Session session = createSession("paulo", "secret", false); session.connect(); ChannelShell channel = (ChannelShell) session.openChannel("shell"); channel.connect(); OutputStream out = channel.getOutputStream(); channel.setPtySize(20, 10, 20 * 8, 10 * 8); out.flush(); channel.disconnect(); session.disconnect(); }
@Test public void testResizeInvalid(TestContext context) { Async async = context.async(); server = createServer(context, new HttpTermOptions().setPort(8080));; server.termHandler(term -> { term.resizehandler(v -> { context.fail(); }); }); server.listen(context.asyncAssertSuccess(server -> { HttpClient client = vertx.createHttpClient(); client.websocket(8080, "localhost", basePath + "/shell/websocket", ws -> { ws.writeFinalTextFrame(new JsonObject().put("action", "resize").put("cols", -50).encode()); vertx.setTimer(1000, id -> { async.complete(); }); }, context::fail); })); }
@Test public void testWindowSize(TestContext context) throws Exception { Async async = context.async(); startTelnet(context, term -> { context.assertEquals(-1, term.width()); context.assertEquals(-1, term.height()); term.resizehandler(v -> { context.assertEquals(10, term.width()); context.assertEquals(20, term.height()); async.complete(); }); }); client.addOptionHandler(new WindowSizeOptionHandler(10, 20, false, false, true, false)); client.connect("localhost", server.actualPort()); }
private void testResize(TestContext context, JsonObject event, int expectedCols, int expectedRows) { Async async = context.async(); server = createServer(context, new HttpTermOptions().setPort(8080));; server.termHandler(term -> { term.resizehandler(v -> { context.assertEquals(expectedCols, term.width()); context.assertEquals(expectedRows, term.height()); async.complete(); }); }); server.listen(context.asyncAssertSuccess(server -> { HttpClient client = vertx.createHttpClient(); client.websocket(8080, "localhost", basePath + "/shell/websocket", ws -> { ws.writeFinalTextFrame(event.encode()); }, context::fail); })); }