Key MQTT client functions: connection, subscription, publishing
Key MQTT client functions: connection, subscription, publishing
(connect uri)
(connect uri
{:keys [client-id persister opts on-delivery-complete
on-connection-lost on-connect-complete on-unhandled-message]
:or {client-id (generate-id) persister nil opts {}}})
Instantiates a new client and connects to MQTT broker.
Options (all keys are optional):
Mqtt connect options: either a map with any of the keys bellow or an instance of MqttConnectOptions
Instantiates a new client and connects to MQTT broker. Options (all keys are optional): * :client-id: a client identifier that is unique on the server being connected to * :persister: the persistence class to use to store in-flight message; if bil then the default persistence mechanism is used * :opts: see Mqtt connect options below * :on-connect-complete: function called after connection to broker * :on-connection-lost: function called when connection to broker is lost * :on-delivery-complete: function called when sending and delivery for a message has been completed (depending on its QoS), and all acknowledgments have been received * :on-unhandled-message: function called when a message has arrived and hasn't been handled by a per subscription handler; invoked with 3 arguments: the topic message was received on, an immutable map of message metadata, a byte array of message payload Mqtt connect options: either a map with any of the keys bellow or an instance of MqttConnectOptions * :username (string) * :password (string or char array) * :auto-reconnect (bool) * :connection-timeout (int) * :clean-session (bool) * :keep-alive-interval (int) * :max-in-flight (int) * :socket-factory (SocketFactory) * :will {:topic :payload :qos :retain}
(connected? client)
Returns true if client is currently connected
Returns true if client is currently connected
(disconnect client)
(disconnect client timeout)
Disconnects from MQTT broker.
Disconnects from MQTT broker.
(disconnect-and-close client)
(disconnect-and-close client timeout)
Disconnects from MQTT broker and releases all resources.
Disconnects from MQTT broker and releases all resources.
(generate-id)
Generates a client id.
Limits client id to 23 bytes, per MQTT spec
Generates a client id. Limits client id to 23 bytes, per MQTT spec
(pending-delivery-tokens client)
Retuns pending message delivery tokens, if any.
If all messages were published successfully after last client termination, returns an empty collection.
Retuns pending message delivery tokens, if any. If all messages were published successfully after last client termination, returns an empty collection.
(pending-messages client)
Retuns pending messages, if any.
If all messages were published successfully after last client termination, returns an empty collection.
Retuns pending messages, if any. If all messages were published successfully after last client termination, returns an empty collection.
(prepare uri client-id persister)
Instantiates a new client
Instantiates a new client
(publish client topic payload)
(publish client topic payload qos)
(publish client topic payload qos retained?)
Publishes a message to a topic.
Publishes a message to a topic.
(subscribe client topics-and-qos handler-fn)
Subscribes to one or multiple topics (if topics
is a collection
or sequence).
Provided handler function will be invoked with 3 arguments:
BEWARE: Don't use dots in topic names with RabbitMQ - see rabbitmq-mqtt/issues/58
Subscribes to one or multiple topics (if `topics` is a collection or sequence). Provided handler function will be invoked with 3 arguments: * The topic message was received on * Immutable map of message metadata * Byte array of message payload BEWARE: Don't use dots in topic names with RabbitMQ - see rabbitmq-mqtt/issues/58
(unsubscribe client topics)
Unsubscribes from one or multiple topics (if topics
is a collection
or sequence)
Unsubscribes from one or multiple topics (if `topics` is a collection or sequence)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close