Skip to content
Open
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This project provides the following two different components :
* **server** : it's able to handle connections, communication and messages exchange with remote [MQTT](http://mqtt.org/) clients.
Its API provides a bunch of events related to raw protocol messages received by clients and exposes some functionalities in order to send messages to them.
It's not a fully featured MQTT broker but can be used for building something like that or for protocol translation (MQTT <--> ?).
* **client** : it's an [MQTT](http://mqtt.org/) client which is compliant with the 3.1.1 spec. Its API provides a bunch of methods
* **client** : it's an [MQTT](http://mqtt.org/) client which is compliant with both the 3.1.1 and 5.0 specs. Its API provides a bunch of methods
for connecting/disconnecting to a broker, publishing messages (with all three different levels of QoS) and subscribing to topics.

See the in-source docs for more details:
Expand Down
467 changes: 466 additions & 1 deletion src/main/asciidoc/index.adoc

Large diffs are not rendered by default.

98 changes: 74 additions & 24 deletions src/main/generated/io/vertx/mqtt/MqttClientOptionsConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json, MqttCli
obj.setAckTimeout(((Number)member.getValue()).intValue());
}
break;
case "authenticationData":
if (member.getValue() instanceof String) {
obj.setAuthenticationData(io.vertx.core.buffer.Buffer.buffer(BASE64_DECODER.decode((String)member.getValue())));
}
break;
case "authenticationMethod":
if (member.getValue() instanceof String) {
obj.setAuthenticationMethod((String)member.getValue());
}
break;
case "autoAck":
if (member.getValue() instanceof Boolean) {
obj.setAutoAck((Boolean)member.getValue());
Expand All @@ -40,6 +50,11 @@ static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json, MqttCli
obj.setAutoKeepAlive((Boolean)member.getValue());
}
break;
case "autoServerRedirect":
if (member.getValue() instanceof Boolean) {
obj.setAutoServerRedirect((Boolean)member.getValue());
}
break;
case "cleanSession":
if (member.getValue() instanceof Boolean) {
obj.setCleanSession((Boolean)member.getValue());
Expand All @@ -65,44 +80,59 @@ static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json, MqttCli
obj.setMaxMessageSize(((Number)member.getValue()).intValue());
}
break;
case "maximumPacketSize":
if (member.getValue() instanceof Number) {
obj.setMaximumPacketSize(((Number)member.getValue()).longValue());
}
break;
case "password":
if (member.getValue() instanceof String) {
obj.setPassword((String)member.getValue());
}
break;
case "receiveMaximum":
if (member.getValue() instanceof Number) {
obj.setReceiveMaximum(((Number)member.getValue()).intValue());
}
break;
case "recvByteBufAllocatorSize":
if (member.getValue() instanceof Number) {
obj.setRecvByteBufAllocatorSize(((Number)member.getValue()).intValue());
}
break;
case "username":
if (member.getValue() instanceof String) {
obj.setUsername((String)member.getValue());
case "requestProblemInformation":
if (member.getValue() instanceof Boolean) {
obj.setRequestProblemInformation((Boolean)member.getValue());
}
break;
case "willFlag":
case "requestResponseInformation":
if (member.getValue() instanceof Boolean) {
obj.setWillFlag((Boolean)member.getValue());
obj.setRequestResponseInformation((Boolean)member.getValue());
}
break;
case "willMessageBytes":
if (member.getValue() instanceof String) {
obj.setWillMessageBytes(io.vertx.core.buffer.Buffer.buffer(BASE64_DECODER.decode((String)member.getValue())));
case "sessionExpireInterval":
if (member.getValue() instanceof Number) {
obj.setSessionExpireInterval(((Number)member.getValue()).longValue());
}
break;
case "willQoS":
case "topicAliasMaximum":
if (member.getValue() instanceof Number) {
obj.setWillQoS(((Number)member.getValue()).intValue());
obj.setTopicAliasMaximum(((Number)member.getValue()).intValue());
}
break;
case "willRetain":
if (member.getValue() instanceof Boolean) {
obj.setWillRetain((Boolean)member.getValue());
case "username":
if (member.getValue() instanceof String) {
obj.setUsername((String)member.getValue());
}
break;
case "willTopic":
if (member.getValue() instanceof String) {
obj.setWillTopic((String)member.getValue());
case "version":
if (member.getValue() instanceof Number) {
obj.setVersion(((Number)member.getValue()).intValue());
}
break;
case "willOptions":
if (member.getValue() instanceof JsonObject) {
obj.setWillOptions(new io.vertx.mqtt.MqttClientWillOptions((io.vertx.core.json.JsonObject)member.getValue()));
}
break;
}
Expand All @@ -115,31 +145,51 @@ static void toJson(MqttClientOptions obj, JsonObject json) {

static void toJson(MqttClientOptions obj, java.util.Map<String, Object> json) {
json.put("ackTimeout", obj.getAckTimeout());
if (obj.getAuthenticationData() != null) {
json.put("authenticationData", BASE64_ENCODER.encodeToString(obj.getAuthenticationData().getBytes()));
}
if (obj.getAuthenticationMethod() != null) {
json.put("authenticationMethod", obj.getAuthenticationMethod());
}
json.put("autoAck", obj.isAutoAck());
json.put("autoGeneratedClientId", obj.isAutoGeneratedClientId());
json.put("autoKeepAlive", obj.isAutoKeepAlive());
json.put("autoServerRedirect", obj.isAutoServerRedirect());
json.put("cleanSession", obj.isCleanSession());
if (obj.getClientId() != null) {
json.put("clientId", obj.getClientId());
}
json.put("keepAliveInterval", obj.getKeepAliveInterval());
json.put("maxInflightQueue", obj.getMaxInflightQueue());
json.put("maxMessageSize", obj.getMaxMessageSize());
if (obj.getMaximumPacketSize() != null) {
json.put("maximumPacketSize", obj.getMaximumPacketSize());
}
if (obj.getPassword() != null) {
json.put("password", obj.getPassword());
}
if (obj.getReceiveMaximum() != null) {
json.put("receiveMaximum", obj.getReceiveMaximum());
}
json.put("recvByteBufAllocatorSize", obj.getRecvByteBufAllocatorSize());
if (obj.getRequestProblemInformation() != null) {
json.put("requestProblemInformation", obj.getRequestProblemInformation());
}
if (obj.getRequestResponseInformation() != null) {
json.put("requestResponseInformation", obj.getRequestResponseInformation());
}
if (obj.getSessionExpireInterval() != null) {
json.put("sessionExpireInterval", obj.getSessionExpireInterval());
}
if (obj.getTopicAliasMaximum() != null) {
json.put("topicAliasMaximum", obj.getTopicAliasMaximum());
}
if (obj.getUsername() != null) {
json.put("username", obj.getUsername());
}
json.put("willFlag", obj.isWillFlag());
if (obj.getWillMessageBytes() != null) {
json.put("willMessageBytes", BASE64_ENCODER.encodeToString(obj.getWillMessageBytes().getBytes()));
}
json.put("willQoS", obj.getWillQoS());
json.put("willRetain", obj.isWillRetain());
if (obj.getWillTopic() != null) {
json.put("willTopic", obj.getWillTopic());
json.put("version", obj.getVersion());
if (obj.getWillOptions() != null) {
json.put("willOptions", obj.getWillOptions().toJson());
}
}
}
124 changes: 124 additions & 0 deletions src/main/generated/io/vertx/mqtt/MqttClientWillOptionsConverter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package io.vertx.mqtt;

import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.impl.JsonUtil;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.util.Base64;

/**
* Converter and mapper for {@link io.vertx.mqtt.MqttClientWillOptions}.
* NOTE: This class has been automatically generated from the {@link io.vertx.mqtt.MqttClientWillOptions} original class using Vert.x codegen.
*/
public class MqttClientWillOptionsConverter {


private static final Base64.Decoder BASE64_DECODER = JsonUtil.BASE64_DECODER;
private static final Base64.Encoder BASE64_ENCODER = JsonUtil.BASE64_ENCODER;

static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json, MqttClientWillOptions obj) {
for (java.util.Map.Entry<String, Object> member : json) {
switch (member.getKey()) {
case "contentType":
if (member.getValue() instanceof String) {
obj.setContentType((String)member.getValue());
}
break;
case "correlationData":
if (member.getValue() instanceof String) {
obj.setCorrelationData(io.vertx.core.buffer.Buffer.buffer(BASE64_DECODER.decode((String)member.getValue())));
}
break;
case "messageBytes":
if (member.getValue() instanceof String) {
obj.setMessageBytes(io.vertx.core.buffer.Buffer.buffer(BASE64_DECODER.decode((String)member.getValue())));
}
break;
case "payloadFormatIndicator":
if (member.getValue() instanceof Number) {
obj.setPayloadFormatIndicator(((Number)member.getValue()).intValue());
}
break;
case "qos":
if (member.getValue() instanceof Number) {
obj.setQos(((Number)member.getValue()).intValue());
}
break;
case "responseTopic":
if (member.getValue() instanceof String) {
obj.setResponseTopic((String)member.getValue());
}
break;
case "retain":
if (member.getValue() instanceof Boolean) {
obj.setRetain((Boolean)member.getValue());
}
break;
case "topic":
if (member.getValue() instanceof String) {
obj.setTopic((String)member.getValue());
}
break;
case "userProperties":
if (member.getValue() instanceof JsonObject) {
java.util.Map<String, java.lang.String> map = new java.util.LinkedHashMap<>();
((Iterable<java.util.Map.Entry<String, Object>>)member.getValue()).forEach(entry -> {
if (entry.getValue() instanceof String)
map.put(entry.getKey(), (String)entry.getValue());
});
obj.setUserProperties(map);
}
break;
case "userPropertys":
if (member.getValue() instanceof JsonObject) {
((Iterable<java.util.Map.Entry<String, Object>>)member.getValue()).forEach(entry -> {
if (entry.getValue() instanceof String)
obj.addUserProperty(entry.getKey(), (String)entry.getValue());
});
}
break;
case "willDelayInterval":
if (member.getValue() instanceof Number) {
obj.setWillDelayInterval(((Number)member.getValue()).longValue());
}
break;
}
}
}

static void toJson(MqttClientWillOptions obj, JsonObject json) {
toJson(obj, json.getMap());
}

static void toJson(MqttClientWillOptions obj, java.util.Map<String, Object> json) {
if (obj.getContentType() != null) {
json.put("contentType", obj.getContentType());
}
if (obj.getCorrelationData() != null) {
json.put("correlationData", BASE64_ENCODER.encodeToString(obj.getCorrelationData().getBytes()));
}
if (obj.getMessageBytes() != null) {
json.put("messageBytes", BASE64_ENCODER.encodeToString(obj.getMessageBytes().getBytes()));
}
if (obj.getPayloadFormatIndicator() != null) {
json.put("payloadFormatIndicator", obj.getPayloadFormatIndicator());
}
json.put("qos", obj.getQos());
if (obj.getResponseTopic() != null) {
json.put("responseTopic", obj.getResponseTopic());
}
json.put("retain", obj.isRetain());
if (obj.getTopic() != null) {
json.put("topic", obj.getTopic());
}
if (obj.getUserProperties() != null) {
JsonObject map = new JsonObject();
obj.getUserProperties().forEach((key, value) -> map.put(key, value));
json.put("userProperties", map);
}
if (obj.getWillDelayInterval() != null) {
json.put("willDelayInterval", obj.getWillDelayInterval());
}
}
}
Loading
Loading