Search in sources :

Example 1 with ShellServer

use of io.vertx.ext.shell.ShellServer 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();
        }
    });
}
Also used : ShellServer(io.vertx.ext.shell.ShellServer) TermServer(io.vertx.ext.shell.term.TermServer) TelnetTermServer(io.vertx.ext.shell.term.impl.TelnetTermServer) TelnetTermOptions(io.vertx.ext.shell.term.TelnetTermOptions) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Aggregations

ShellServer (io.vertx.ext.shell.ShellServer)1 TelnetTermOptions (io.vertx.ext.shell.term.TelnetTermOptions)1 TermServer (io.vertx.ext.shell.term.TermServer)1 TelnetTermServer (io.vertx.ext.shell.term.impl.TelnetTermServer)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1