@Override public void start(Future<Void> startFuture) throws Exception { termServer = TermServer.createTelnetTermServer(vertx, new TelnetTermOptions().setHost("localhost").setPort(3000).setInBinary(false)); Robot robot = new Robot(); termServer.termHandler(term -> { new ScreenCaster(vertx, robot, term).handle(); }); termServer.listen(ar -> { if (ar.succeeded()) { startFuture.complete(); } else { startFuture.fail(ar.cause()); } }); }
}); }); TelnetTermOptions tto = new TelnetTermOptions().setPort(3000).setHost("localhost"); TermServer telnetTermServer = TermServer.createTelnetTermServer(vertx,tto); server.registerTermServer(telnetTermServer);
new TelnetTermOptions().setHost("localhost").setPort(3000) )); CommandRegistry.getShared(vertx).registerCommand(starwars);
@Override public void start() throws Exception { ShellService service = ShellService.create(vertx, new ShellServiceOptions().setTelnetOptions( new TelnetTermOptions().setHost("localhost").setPort(3000) )); service.start(); } }
@Override public void start() throws Exception { Command helloWorld = CommandBuilder.command("hello-world"). processHandler(process -> { process.write("hello world\n"); process.end(); }).build(vertx); ShellService service = ShellService.create(vertx, new ShellServiceOptions().setTelnetOptions( new TelnetTermOptions().setHost("localhost").setPort(3000) )); CommandRegistry.getShared(vertx).registerCommand(helloWorld); service.start(ar -> { if (!ar.succeeded()) { ar.cause().printStackTrace(); } }); } }
@Override public void start() throws Exception { Command starwars = CommandBuilder.command("echokeyboard"). processHandler(process -> { // Echo process.stdinHandler(keys -> { process.write(keys.replace('\r', '\n')); }); // Terminate when user hits Ctrl-C process.interruptHandler(v -> { process.end(); }); }).build(vertx); ShellService service = ShellService.create(vertx, new ShellServiceOptions().setTelnetOptions( new TelnetTermOptions().setHost("localhost").setPort(3000) )); CommandRegistry.getShared(vertx).registerCommand(starwars); service.start(ar -> { if (!ar.succeeded()) { ar.cause().printStackTrace(); } }); } }
new TelnetTermOptions().setHost("localhost").setPort(3000) )); CommandRegistry.getShared(vertx).registerCommand(starwars);
new TelnetTermOptions().setHost("localhost").setPort(3000) )); CommandRegistry.getShared(vertx).registerCommand(helloWorld);
public TelnetTermServer(Vertx vertx, TelnetTermOptions options) { this.vertx = vertx; this.options = new TelnetTermOptions(options); }
/** * Create a term server for the Telnet protocol. * * @param vertx the vertx instance * @return the term server */ static TermServer createTelnetTermServer(Vertx vertx) { return createTelnetTermServer(vertx, new TelnetTermOptions()); }
public ShellServiceOptions(ShellServiceOptions that) { super(that); this.telnetOptions = that.telnetOptions != null ? new TelnetTermOptions(that.telnetOptions) : null; this.sshOptions = that.sshOptions != null ? new SSHTermOptions(that.sshOptions) : null; this.httpOptions = that.httpOptions != null ? new HttpTermOptions(that.httpOptions) : null; }
public static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json, ShellServiceOptions obj) { for (java.util.Map.Entry<String, Object> member : json) { switch (member.getKey()) { case "httpOptions": if (member.getValue() instanceof JsonObject) { obj.setHttpOptions(new io.vertx.ext.shell.term.HttpTermOptions((JsonObject)member.getValue())); } break; case "sshOptions": if (member.getValue() instanceof JsonObject) { obj.setSSHOptions(new io.vertx.ext.shell.term.SSHTermOptions((JsonObject)member.getValue())); } break; case "telnetOptions": if (member.getValue() instanceof JsonObject) { obj.setTelnetOptions(new io.vertx.ext.shell.term.TelnetTermOptions((JsonObject)member.getValue())); } break; } } }
public static io.vertx.ext.shell.term.TermServer createTelnetTermServer(io.vertx.ext.shell.term.TermServer j_receiver, io.vertx.core.Vertx vertx, java.util.Map<String, Object> options) { return io.vertx.core.impl.ConversionHelper.fromObject(io.vertx.ext.shell.term.TermServer.createTelnetTermServer(vertx, options != null ? new io.vertx.ext.shell.term.TelnetTermOptions(io.vertx.core.impl.ConversionHelper.toJsonObject(options)) : null)); } public static io.vertx.ext.shell.term.TermServer createHttpTermServer(io.vertx.ext.shell.term.TermServer j_receiver, io.vertx.core.Vertx vertx, java.util.Map<String, Object> options) {
private void startTelnet(TestContext context, Handler<Term> termHandler) { startTelnet(context, new TelnetTermOptions(), termHandler); }
@Test public void testKeymapFromFilesystem(TestContext context) throws Exception { URL url = TermServer.class.getResource(SSHTermOptions.DEFAULT_INPUTRC); File f = new File(url.toURI()); startTelnet(context, new TelnetTermOptions().setIntputrc(f.getAbsolutePath()), Term::close); client.connect("localhost", server.actualPort()); } }
@Test public void testDifferentCharset(TestContext context) throws Exception { CompletableFuture<Void> closeLatch = new CompletableFuture<Void>(); startTelnet(context, new TelnetTermOptions().setCharset("ISO_8859_1"), term -> { term.write("\u20AC"); closeLatch.thenAccept(v -> { term.close(); }); }); client.connect("localhost", server.actualPort()); InputStream in = client.getInputStream(); int b = in.read(); context.assertEquals(63, b); closeLatch.complete(null); }
@Test public void testOutBinaryFalse(TestContext context) throws Exception { byte[] expected = StandardCharsets.US_ASCII.encode("€").array(); startTelnet(context, new TelnetTermOptions().setOutBinary(false), term -> { term.write("\u20AC"); }); client.addOptionHandler(new WindowSizeOptionHandler(10, 20, false, false, true, false)); client.connect("localhost", server.actualPort()); InputStream in = client.getInputStream(); for (int i = 0;i < expected.length;i++) { context.assertEquals((int)expected[i], in.read()); } }
@Test public void testOutBinaryTrue(TestContext context) throws Exception { startTelnet(context, new TelnetTermOptions().setOutBinary(true), term -> { term.write("\u20AC"); }); client.addOptionHandler(new WindowSizeOptionHandler(10, 20, false, false, true, false)); client.connect("localhost", server.actualPort()); InputStream in = client.getInputStream(); context.assertEquals(226, in.read()); context.assertEquals(130, in.read()); context.assertEquals(172, in.read()); }
); ShellService service = ShellService.create(vertx, new ShellServiceOptions(). setTelnetOptions(new TelnetTermOptions().setPort(5000)). setSSHOptions(options). setHttpOptions(new HttpTermOptions().