public static void toJson(MqttClientOptions obj, java.util.Map<String, Object> json) { json.put("autoGeneratedClientId", obj.isAutoGeneratedClientId()); json.put("autoKeepAlive", obj.isAutoKeepAlive()); json.put("cleanSession", obj.isCleanSession()); if (obj.getClientId() != null) { json.put("clientId", obj.getClientId()); } json.put("keepAliveTimeSeconds", obj.getKeepAliveTimeSeconds()); json.put("maxInflightQueue", obj.getMaxInflightQueue()); json.put("maxMessageSize", obj.getMaxMessageSize()); if (obj.getPassword() != null) { json.put("password", obj.getPassword()); } if (obj.getUsername() != null) { json.put("username", obj.getUsername()); } json.put("willFlag", obj.isWillFlag()); if (obj.getWillMessage() != null) { json.put("willMessage", obj.getWillMessage()); } json.put("willQoS", obj.getWillQoS()); json.put("willRetain", obj.isWillRetain()); if (obj.getWillTopic() != null) { json.put("willTopic", obj.getWillTopic()); } } }
public static void toJson(MqttClientOptions obj, java.util.Map<String, Object> json) { json.put("autoGeneratedClientId", obj.isAutoGeneratedClientId()); json.put("autoKeepAlive", obj.isAutoKeepAlive()); json.put("cleanSession", obj.isCleanSession()); if (obj.getClientId() != null) { json.put("clientId", obj.getClientId()); } json.put("keepAliveTimeSeconds", obj.getKeepAliveTimeSeconds()); json.put("maxInflightQueue", obj.getMaxInflightQueue()); json.put("maxMessageSize", obj.getMaxMessageSize()); if (obj.getPassword() != null) { json.put("password", obj.getPassword()); } if (obj.getUsername() != null) { json.put("username", obj.getUsername()); } json.put("willFlag", obj.isWillFlag()); if (obj.getWillMessage() != null) { json.put("willMessage", obj.getWillMessage()); } json.put("willQoS", obj.getWillQoS()); json.put("willRetain", obj.isWillRetain()); if (obj.getWillTopic() != null) { json.put("willTopic", obj.getWillTopic()); } } }
private void initChannel(ChannelPipeline pipeline) { // add into pipeline netty's (en/de)coder pipeline.addBefore("handler", "mqttEncoder", MqttEncoder.INSTANCE); if (this.options.getMaxMessageSize() > 0) { pipeline.addBefore("handler", "mqttDecoder", new MqttDecoder(this.options.getMaxMessageSize())); } else { // max message size not set, so the default from Netty MQTT codec is used pipeline.addBefore("handler", "mqttDecoder", new MqttDecoder()); } if (this.options.isAutoKeepAlive() && this.options.getKeepAliveTimeSeconds() != 0) { pipeline.addBefore("handler", "idle", new IdleStateHandler(0, this.options.getKeepAliveTimeSeconds(), 0)); pipeline.addBefore("handler", "keepAliveHandler", new ChannelDuplexHandler() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof IdleStateEvent) { IdleStateEvent e = (IdleStateEvent) evt; if (e.state() == IdleState.WRITER_IDLE) { ping(); } } } }); } }
private void initChannel(ChannelPipeline pipeline) { // add into pipeline netty's (en/de)coder pipeline.addBefore("handler", "mqttEncoder", MqttEncoder.INSTANCE); if (this.options.getMaxMessageSize() > 0) { pipeline.addBefore("handler", "mqttDecoder", new MqttDecoder(this.options.getMaxMessageSize())); } else { // max message size not set, so the default from Netty MQTT codec is used pipeline.addBefore("handler", "mqttDecoder", new MqttDecoder()); } if (this.options.isAutoKeepAlive() && this.options.getKeepAliveTimeSeconds() != 0) { pipeline.addBefore("handler", "idle", new IdleStateHandler(0, this.options.getKeepAliveTimeSeconds(), 0)); pipeline.addBefore("handler", "keepAliveHandler", new ChannelDuplexHandler() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof IdleStateEvent) { IdleStateEvent e = (IdleStateEvent) evt; if (e.state() == IdleState.WRITER_IDLE) { ping(); } } } }); } }