@Override public void start() throws Exception { MqttClientOptions options = new MqttClientOptions().setKeepAliveTimeSeconds(2);
/** * Do the same thing as {@link MqttClientOptions#setKeepAliveTimeSeconds(int)}. Use it instead. */ @Deprecated @Override public MqttClientOptions setIdleTimeout(int idleTimeout) { return setKeepAliveTimeSeconds(idleTimeout); }
/** * Do the same thing as {@link MqttClientOptions#setKeepAliveTimeSeconds(int)}. Use it instead. */ @Deprecated @Override public MqttClientOptions setIdleTimeout(int idleTimeout) { return setKeepAliveTimeSeconds(idleTimeout); }
case "keepAliveTimeSeconds": if (member.getValue() instanceof Number) { obj.setKeepAliveTimeSeconds(((Number)member.getValue()).intValue());
case "keepAliveTimeSeconds": if (member.getValue() instanceof Number) { obj.setKeepAliveTimeSeconds(((Number)member.getValue()).intValue());
@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 autoPing(TestContext context) throws InterruptedException { Async async = context.async(); MqttClientOptions options = new MqttClientOptions(); options.setKeepAliveTimeSeconds(KEEPALIVE_TIMEOUT); log.info("Auto ping ... " + PING_NUMBER + " times timeout " + KEEPALIVE_TIMEOUT); count = 0; MqttClient client = MqttClient.create(Vertx.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) { client.disconnect(); async.countDown(); } }); }); async.await(); } }
@Test public void autoPing(TestContext context) throws InterruptedException { Async async = context.async(); MqttClientOptions options = new MqttClientOptions(); options.setKeepAliveTimeSeconds(KEEPALIVE_TIMEOUT); log.info("Auto ping ... " + PING_NUMBER + " times timeout " + KEEPALIVE_TIMEOUT); count = 0; MqttClient client = MqttClient.create(Vertx.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) { client.disconnect(); async.countDown(); } }); }); async.await(); } }