use of io.vertx.ext.shell.term.TermServer in project vertx-examples by vert-x3.
the class PromptCommand method start.
@Override
public void start() throws Exception {
ShellServer server = ShellServer.create(vertx);
AtomicInteger ai = new AtomicInteger(0);
server.shellHandler(shell -> {
shell.setPrompt(s -> {
try {
return "C: " + ai.incrementAndGet();
} catch (Exception e) {
System.err.println("Counter");
e.printStackTrace();
}
return "NOOP";
});
});
TelnetTermOptions tto = new TelnetTermOptions().setPort(3000).setHost("localhost");
TermServer telnetTermServer = TermServer.createTelnetTermServer(vertx, tto);
server.registerTermServer(telnetTermServer);
server.registerCommandResolver(CommandResolver.baseCommands(vertx));
server.listen(ar -> {
if (!ar.succeeded()) {
ar.cause().printStackTrace();
}
});
}
Aggregations