case "autoKeepAlive": if (member.getValue() instanceof Boolean) { obj.setAutoKeepAlive((Boolean)member.getValue());
case "autoKeepAlive": if (member.getValue() instanceof Boolean) { obj.setAutoKeepAlive((Boolean)member.getValue());
@Test public void closeHandler(TestContext context) throws InterruptedException { Async async = context.async(); MqttClient client = MqttClient.create(Vertx.vertx(), new MqttClientOptions() .setKeepAliveTimeSeconds(5) .setAutoKeepAlive(false) ); client.closeHandler((v) -> { async.countDown(); }); client.connect(TestUtil.BROKER_PORT, TestUtil.BROKER_ADDRESS, c -> { assertTrue(c.succeeded()); }); async.await(); }
@Test public void closeHandler(TestContext context) throws InterruptedException { Async async = context.async(); MqttClient client = MqttClient.create(Vertx.vertx(), new MqttClientOptions() .setKeepAliveTimeSeconds(5) .setAutoKeepAlive(false) ); client.closeHandler((v) -> { async.countDown(); }); client.connect(TestUtil.BROKER_PORT, TestUtil.BROKER_ADDRESS, c -> { assertTrue(c.succeeded()); }); async.await(); }
@Test public void manualPing(TestContext context) throws InterruptedException { Vertx vertx = Vertx.vertx(); Async async = context.async(); MqttClientOptions options = new MqttClientOptions(); options.setAutoKeepAlive(false); log.info("Manual ping ... " + PING_NUMBER + " times timeout " + KEEPALIVE_TIMEOUT); count = 0; MqttClient client = MqttClient.create(vertx, options); client.connect(TestUtil.BROKER_PORT, TestUtil.BROKER_ADDRESS, c -> { assertTrue(c.succeeded()); client.pingResponseHandler(v ->{ log.info("Pingresp <-- "); count++; if (count == PING_NUMBER) { vertx.cancelTimer(timerId); client.disconnect(); async.countDown(); } }); vertx.setPeriodic(KEEPALIVE_TIMEOUT * 1000, t -> { timerId = t; log.info("Pingreq --> "); client.ping(); }); }); async.await(); }
@Test public void manualPing(TestContext context) throws InterruptedException { Vertx vertx = Vertx.vertx(); Async async = context.async(); MqttClientOptions options = new MqttClientOptions(); options.setAutoKeepAlive(false); log.info("Manual ping ... " + PING_NUMBER + " times timeout " + KEEPALIVE_TIMEOUT); count = 0; MqttClient client = MqttClient.create(vertx, options); client.connect(TestUtil.BROKER_PORT, TestUtil.BROKER_ADDRESS, c -> { assertTrue(c.succeeded()); client.pingResponseHandler(v ->{ log.info("Pingresp <-- "); count++; if (count == PING_NUMBER) { vertx.cancelTimer(timerId); client.disconnect(); async.countDown(); } }); vertx.setPeriodic(KEEPALIVE_TIMEOUT * 1000, t -> { timerId = t; log.info("Pingreq --> "); client.ping(); }); }); async.await(); }