@Override public void stop() throws Exception { termServer.close(); } }
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 void handle() { if (term.width() > 0 && term.height() > 0) { broadcast(); } else { term.resizehandler(v -> { broadcast(); }); } }
@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()); } }); }
@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(Future<Void> startFuture) throws Exception { ShellService service = ShellService.create(vertx, new ShellServiceOptions(). setSSHOptions( new SSHTermOptions(). setHost("localhost"). setPort(3000). setKeyPairOptions(new JksOptions(). setPath("keystore.jks"). setPassword("wibble")). setAuthOptions(new ShiroAuthOptions(). setConfig(new JsonObject().put("properties_path", "auth.properties"))))); service.start(ar -> { if (ar.succeeded()) { startFuture.succeeded(); } else { startFuture.fail(ar.cause()); } }); } }
}); }); TelnetTermOptions tto = new TelnetTermOptions().setPort(3000).setHost("localhost"); TermServer telnetTermServer = TermServer.createTelnetTermServer(vertx,tto); server.registerTermServer(telnetTermServer);
private void broadcast() { if (interrupted) { term.close(); return; int width = term.width(); int height = term.height(); Image temp = capture.getScaledInstance(width, height, Image.SCALE_SMOOTH); BufferedImage scaled = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); term.write(sb.toString()); vertx.setTimer(100, v -> broadcast());
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; }
/** * Create a term server for the HTTP protocol, using an existing router. * * @param vertx the vertx instance * @param router the router * @return the term server */ static TermServer createHttpTermServer(Vertx vertx, Router router) { return createHttpTermServer(vertx, router, new HttpTermOptions()); }
@Override public void start(Future<Void> startFuture) throws Exception { ShellService service = ShellService.create(vertx, new ShellServiceOptions(). setHttpOptions( new HttpTermOptions(). setHost("localhost"). setPort(8080). setAuthOptions(new ShiroAuthOptions(). setConfig(new JsonObject().put("properties_path", "auth.properties"))))); service.start(ar -> { if (ar.succeeded()) { startFuture.succeeded(); } else { startFuture.fail(ar.cause()); } }); } }
/** * 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()); }
/** * Create a term server for the SSH protocol. * * @param vertx the vertx instance * @return the term server */ static TermServer createSSHTermServer(Vertx vertx) { return createSSHTermServer(vertx, new SSHTermOptions()); }
@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(); } }); } }
/** * Create a term server for the HTTP protocol. * * @param vertx the vertx instance * @return the term server */ static TermServer createHttpTermServer(Vertx vertx) { return createHttpTermServer(vertx, new HttpTermOptions()); }
@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(starwars);
new TelnetTermOptions().setHost("localhost").setPort(3000) )); CommandRegistry.getShared(vertx).registerCommand(helloWorld);