(capture-all-packets ch xf)
Typically used with xf via packet-filter
.
Typically used with xf via `packet-filter`.
(capture-first-packet ch xf)
Typically used with xf via packet-filter
.
Typically used with xf via `packet-filter`.
(client {:keys [broker-url default-root-topic] :as opts})
Accepts the following parameters:
Accepts the following parameters: - broker-url (required) - url of the form ws(s)://(user:password@)host:12345/path(#some/root-topic). The root-topic is prepended to all subscribes/publishes and ensures that the client only needs to care about topics that are relevant for the application, e.g. "temperature/current" (instead of "staging/sensor0/temperature/current"). You can provide a default-topic-root. - default-root-topic - root-topic used when broker-url does not contain one. This e.g. allows the client-logic to subscribe to "#" knowing that it won't subscribe to the root of a broker. - keep-alive (default 60) - maximum seconds between pings. - client-id (default "otarta-<random-uuid>") - Client Identifier used to connect to broker.
(connect client)
Connect with broker. Idempotent.
Typically there's no need to call this as it's called from publish
and subscribe
.
Connect with broker. Idempotent. Typically there's no need to call this as it's called from `publish` and `subscribe`.
(generate-payload-formatter read-write format)
(mqtt-connect {:keys [stream config] :as client})
(mqtt-disconnect {stream :stream :as client})
(packet-filter matchers)
Yield xf that filters a packet against matchers.
Matchers come in a map, like:
You can provide a predicate:
Yield xf that filters a packet against matchers. Matchers come in a map, like: - {[:a :b] 2} match {:a {:b 2}} - {[:a 0 :b] 2} match {:a [{:b 2}]} - {[:a] 1 [:b] 3} does *not* match {:a 1 :b 2} - {[:a] nil} does *not* match {} (cause there's no :a) You can provide a predicate: - {[:a :b] odd?} matches {:a {:b 3}}
(parse-broker-url url)
(parse-broker-url url {:keys [default-root-topic]})
(publish client topic msg)
(publish client topic msg opts)
Yields async-channel that returns [err result] when msg is published.
Currently err
is always nil as no check is done whether the
underlying connection is active, nor whether the broker received
the message (ie qos 0).
Yields async-channel that returns [err result] when msg is published. Currently `err` is always nil as no check is done whether the underlying connection is active, nor whether the broker received the message (ie qos 0).
(send-and-await-response pkt sink source)
(send-and-await-response pkt
sink
source
{:keys [max-wait] :or {max-wait 1000} :as _opts})
(start-pinger {stream :stream {keep-alive :keep-alive} :config :as client})
Keeps mqtt-connection alive by sending pingreq's every keep-alive
seconds.
Keeps mqtt-connection alive by sending pingreq's every `keep-alive` seconds.
(stop-pinger {pinger :pinger :as client})
(stream-connect {{url :ws-url} :config :as client})
(stream-connected? stream)
(stream-disconnect client)
(subscribe client topic-filter)
(subscribe client topic-filter opts)
Yields async-channel that returns [err result] when subscribing was successful.
err
is a keyword indicating what went wrong, or nil when all is
fine.
result
is a map like {:chan channel}
Yields async-channel that returns [err result] when subscribing was successful. `err` is a keyword indicating what went wrong, or nil when all is fine. `result` is a map like {:chan channel}
(tap-ch from-ch new-ch)
(topic-filter-matches-topic? topic-filter topic)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close