public static void toJson(TelnetTermOptions obj, java.util.Map<String, Object> json) { if (obj.getCharset() != null) { json.put("charset", obj.getCharset()); } json.put("inBinary", obj.getInBinary()); if (obj.getIntputrc() != null) { json.put("intputrc", obj.getIntputrc()); } json.put("outBinary", obj.getOutBinary()); } }
@Override public TermServer listen(Handler<AsyncResult<TermServer>> listenHandler) { Charset charset = Charset.forName(options.getCharset()); if (server == null) { server = vertx.createNetServer(options); Buffer inputrc = Helper.loadResource(vertx.fileSystem(), options.getIntputrc()); if (inputrc == null) { listenHandler.handle(Future.failedFuture("Could not load inputrc from " + options.getIntputrc())); return this; } Keymap keymap = new Keymap(new ByteArrayInputStream(inputrc.getBytes())); TermConnectionHandler connectionHandler = new TermConnectionHandler(vertx, keymap, termHandler); server.connectHandler(new TelnetSocketHandler(vertx, () -> { return new TelnetTtyConnection(options.getInBinary(), options.getOutBinary(), charset, connectionHandler::handle); })); server.listen(ar -> { if (ar.succeeded()) { listenHandler.handle(Future.succeededFuture(this)); } else { listenHandler.handle(Future.failedFuture(ar.cause())); } }); } else { listenHandler.handle(Future.failedFuture("Already started")); } return this; }