}); server.listen(ar -> { if (ar.succeeded()) { System.out.println("MQTT server started and listening on port " + server.actualPort());
.listen(ar -> {
}); }) .listen(1883, "0.0.0.0", ar -> {
/** * Start the server listening for incoming connections using the specified options * through the constructor * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.mqtt.MqttServer listen() { delegate.listen(); return this; }
/** * Start the server listening for incoming connections on the port and host specified * @param port the port to listen on * @param host the host to listen on * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.mqtt.MqttServer listen(int port, String host) { delegate.listen(port, host); return this; }
/** * Start the server listening for incoming connections on the port specified but on * "0.0.0.0" as host. It ignores any options specified through the constructor * @param port the port to listen on * @return a reference to this, so the API can be used fluently */ public MqttServer listen(int port) { delegate.listen(port); return this; }
/** * Start the server listening for incoming connections on the port specified but on * "0.0.0.0" as host. It ignores any options specified through the constructor * @param port the port to listen on * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.mqtt.MqttServer listen(int port) { delegate.listen(port); return this; }
/** * Start the server listening for incoming connections using the specified options * through the constructor * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.mqtt.MqttServer listen() { delegate.listen(); return this; }
/** * Start the server listening for incoming connections on the port and host specified * @param port the port to listen on * @param host the host to listen on * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.mqtt.MqttServer listen(int port, String host) { delegate.listen(port, host); return this; }
/** * Start the server listening for incoming connections on the port specified but on * "0.0.0.0" as host. It ignores any options specified through the constructor * @param port the port to listen on * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.mqtt.MqttServer listen(int port) { delegate.listen(port); return this; }
/** * Start the server listening for incoming connections using the specified options * through the constructor * @return a reference to this, so the API can be used fluently */ public MqttServer listen() { delegate.listen(); return this; }
/** * Start the server listening for incoming connections on the port and host specified * @param port the port to listen on * @param host the host to listen on * @return a reference to this, so the API can be used fluently */ public MqttServer listen(int port, String host) { delegate.listen(port, host); return this; }
/** * Start the server listening for incoming connections using the specified options * through the constructor * @param listenHandler handler called when the asynchronous listen call ends * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.mqtt.MqttServer listen(Handler<AsyncResult<io.vertx.rxjava.mqtt.MqttServer>> listenHandler) { delegate.listen(new Handler<AsyncResult<io.vertx.mqtt.MqttServer>>() { public void handle(AsyncResult<io.vertx.mqtt.MqttServer> ar) { if (ar.succeeded()) { listenHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.mqtt.MqttServer.newInstance(ar.result()))); } else { listenHandler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
/** * Start the server listening for incoming connections using the specified options * through the constructor * @param listenHandler handler called when the asynchronous listen call ends * @return a reference to this, so the API can be used fluently */ public MqttServer listen(Handler<AsyncResult<MqttServer>> listenHandler) { delegate.listen(new Handler<AsyncResult<io.vertx.mqtt.MqttServer>>() { public void handle(AsyncResult<io.vertx.mqtt.MqttServer> ar) { if (ar.succeeded()) { listenHandler.handle(io.vertx.core.Future.succeededFuture(MqttServer.newInstance(ar.result()))); } else { listenHandler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
/** * Start the server listening for incoming connections using the specified options * through the constructor * @param listenHandler handler called when the asynchronous listen call ends * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.mqtt.MqttServer listen(Handler<AsyncResult<io.vertx.rxjava.mqtt.MqttServer>> listenHandler) { delegate.listen(new Handler<AsyncResult<io.vertx.mqtt.MqttServer>>() { public void handle(AsyncResult<io.vertx.mqtt.MqttServer> ar) { if (ar.succeeded()) { listenHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.mqtt.MqttServer.newInstance(ar.result()))); } else { listenHandler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
private Future<MqttServer> bindMqttServer(final MqttServerOptions options, final MqttServer mqttServer) { final Future<MqttServer> result = Future.future(); final MqttServer createdMqttServer = mqttServer == null ? MqttServer.create(this.vertx, options) : mqttServer; createdMqttServer .endpointHandler(this::handleEndpointConnection) .listen(done -> { if (done.succeeded()) { LOG.info("MQTT server running on {}:{}", getConfig().getBindAddress(), createdMqttServer.actualPort()); result.complete(createdMqttServer); } else { LOG.error("error while starting up MQTT server", done.cause()); result.fail(done.cause()); } }); return result; }
private Future<MqttServer> bindMqttServer(final MqttServerOptions options, final MqttServer mqttServer) { final Future<MqttServer> result = Future.future(); final MqttServer createdMqttServer = mqttServer == null ? MqttServer.create(this.vertx, options) : mqttServer; createdMqttServer .endpointHandler(this::handleEndpointConnection) .listen(done -> { if (done.succeeded()) { LOG.info("MQTT server running on {}:{}", getConfig().getBindAddress(), createdMqttServer.actualPort()); result.complete(createdMqttServer); } else { LOG.error("error while starting up MQTT server", done.cause()); result.fail(done.cause()); } }); return result; }
@Before public void before(TestContext context) { server = MqttServer.create(vertx); server.exceptionHandler(t -> context.fail()); server.endpointHandler(MqttClientOutOfOrderAcksTest::serverLogic).listen(context.asyncAssertSuccess()); }
@Before public void before(TestContext context) { server = MqttServer.create(vertx); server.exceptionHandler(t -> context.fail()); server.endpointHandler(MqttClientOutOfOrderAcksTest::serverLogic).listen(context.asyncAssertSuccess()); }
@Before public void before(TestContext ctx) { PemKeyCertOptions pemKeyCertOptions = new PemKeyCertOptions() .setKeyPath("tls/server-key.pem") .setCertPath("tls/server-cert.pem"); MqttServerOptions serverOptions = new MqttServerOptions() .setPort(MQTT_SERVER_TLS_PORT) .setHost(MQTT_SERVER_HOST) .setKeyCertOptions(pemKeyCertOptions) .setSsl(true); server = MqttServer.create(vertx, serverOptions); server.exceptionHandler(t -> context.assertTrue(false)); server.endpointHandler(e -> { log.info("Client connected"); e.disconnectHandler(d -> log.info("Client disconnected")); e.accept(false); }).listen(ctx.asyncAssertSuccess()); }