(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 broker-url)
(client broker-url {:keys [default-root-topic] :as opts})
Initialize a client for publish/subscribe.
Arguments:
Accepts the following options:
Initialize a client for publish/subscribe. Arguments: - broker-url - 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-root-topic. Accepts the following options: - 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 "<client-id-prefix><random>" (max. 23 characters as per MQTT-spec)) - Client Identifier used to connect to broker. This should be unique accross all connected clients. WARNING: Connecting with a client-id that's already in use results in the existing client being disconnected. - client-id-prefix (default "otarta") - convenient to see in the logs of your broker where the client originates from without running the risk of clashing with existing client-id's.
(connect {stream :stream config :config :as 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`.
(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}}
(publish client topic payload)
(publish client topic payload 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}
{:keys [delay] :or {delay 0}})
(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}
(timeout-channels-wont-prevent-nodejs-exit!)
By default any timeout will keep the Node.js event loop active.
This means for example that timeout-channels (involved in pinging every keep-alive seconds) will prevent the cli from exiting, even though the connection to the broker is terminated.
This function ensures that if there's no other activity keeping the event loop running besides timeout-channels, the process may exit.
By default any timeout will keep the Node.js event loop active. This means for example that timeout-channels (involved in pinging every keep-alive seconds) will prevent the cli from exiting, even though the connection to the broker is terminated. This function ensures that if there's no other activity keeping the event loop running besides timeout-channels, the process may exit.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close