TelnetTermOptions tto = new TelnetTermOptions().setPort(3000).setHost("localhost"); TermServer telnetTermServer = TermServer.createTelnetTermServer(vertx,tto); server.registerTermServer(telnetTermServer);
/** * Register a term server to this shell server, the term server lifecycle methods are managed by this shell server. * @param termServer the term server to add * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.shell.ShellServer registerTermServer(io.vertx.rxjava.ext.shell.term.TermServer termServer) { delegate.registerTermServer(termServer.getDelegate()); return this; }
/** * Register a term server to this shell server, the term server lifecycle methods are managed by this shell server. * @param termServer the term server to add * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.shell.ShellServer registerTermServer(io.vertx.rxjava.ext.shell.term.TermServer termServer) { delegate.registerTermServer(termServer.getDelegate()); return this; }
private void startServer(List<CommandResolver> resolvers, Handler<AsyncResult<Void>> startHandler) { TelnetTermOptions telnetOptions = options.getTelnetOptions(); SSHTermOptions sshOptions = options.getSSHOptions(); HttpTermOptions webOptions = options.getHttpOptions(); if (telnetOptions != null) { server.registerTermServer(new TelnetTermServer(vertx, telnetOptions)); } if (sshOptions != null) { server.registerTermServer(new SSHServer(vertx, sshOptions)); } if (webOptions != null) { server.registerTermServer(new HttpTermServer(vertx, webOptions)); } resolvers.forEach(server::registerCommandResolver); server.listen(startHandler); }
private void startShellServer(TestContext context, long sessionTimeout, long reaperInterval) { if (shellServer != null) { throw new IllegalStateException("Already started"); } Async latch = context.async(); shellServer = ShellServer.create(vertx, new ShellServerOptions().setSessionTimeout(sessionTimeout).setReaperInterval(reaperInterval)). registerTermServer(termServer). registerCommandResolver(registry). listen(context.asyncAssertSuccess(v -> latch.complete())); latch.awaitSuccess(20000); }
@Test public void testPrompt(TestContext context) { commands = new TestCommands(vertx); ShellServer server = ShellServer.create(vertx, new ShellServerOptions() .setWelcomeMessage("") .setSessionTimeout(100) .setReaperInterval(100)); server.shellHandler(shell -> shell.setPrompt(s -> "FOOPROMPT")); TestTermServer termServer = new TestTermServer(vertx); server.registerTermServer(termServer); server. registerCommandResolver(CommandResolver.baseCommands(vertx)). registerCommandResolver(commands). listen(context.asyncAssertSuccess()); TestTtyConnection conn = termServer.openConnection(); Async async = context.async(); commands.add(CommandBuilder.command("foo").processHandler(process -> { context.assertEquals(null, conn.checkWritten("FOOPROMPTfoo\n")); process.stdinHandler(cp -> { context.fail(); }); process.endHandler(v -> { async.complete(); } ); process.end(); })); conn.read("foo\r"); async.awaitSuccess(5000); }