Package com.codename1.io.mqtt
package com.codename1.io.mqtt
A small MQTT 3.1.1 client.
MqttClient connects to a broker over plain TCP (tcp://) or over a
WebSocket with the mqtt subprotocol (ws:// and wss://, which is how TLS
is reached: the TCP transport has no TLS), publishes and subscribes at QoS 0
and QoS 1, and delivers every callback on the Codename One EDT.
MqttCodec and MqttPacket are the transport independent packet layer and
work on plain streams. QoS 2 is not implemented: a client never asks a
broker for it, and a packet that needs it is a protocol error.
MqttOptions o = new MqttOptions("tcp://broker.example.com:1883", "my-client");
MqttClient c = new MqttClient();
c.connect(o, new MqttListener() {
public void connected() { c.subscribe("sensors/#", 1); }
public void messageArrived(String topic, byte[] payload, boolean retained) { }
public void connectionLost(String reason) { }
});
-
ClassDescriptionAn MQTT 3.1.1 client for QoS 0 and QoS 1.Encodes and decodes MQTT 3.1.1 control packets on plain streams, so it is independent of the transport.A malformed, oversized or unsupported MQTT packet, or an MQTT protocol violation by the peer.Receives the life cycle and the messages of an
MqttClient.Receives the messages of one subscription made withMqttClient.subscribe(String, int, MqttMessageListener).Everything anMqttClientneeds to open and identify a connection.One MQTT 3.1.1 control packet as a value.Topic names and topic filters: validation and the+/#matching rules of MQTT 3.1.1 section 4.7.