Liking cljdoc? Tell your friends :D

otarta.core


capture-all-packetscljs

(capture-all-packets ch xf)

Typically used with xf via packet-filter.

Typically used with xf via `packet-filter`.
sourceraw docstring

capture-first-packetcljs

(capture-first-packet ch xf)

Typically used with xf via packet-filter.

Typically used with xf via `packet-filter`.
sourceraw docstring

clientcljs

(client broker-url)
(client broker-url {:keys [default-root-topic] :as opts})

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.
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.
sourceraw docstring

connectcljs

(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`.
sourceraw docstring

disconnectcljs

(disconnect client)
sourceraw docstring

mqtt-connectcljs

(mqtt-connect {:keys [stream config] :as client})
source

mqtt-disconnectcljs

(mqtt-disconnect {stream :stream :as client})
source

mqtt-formatcljs

Read and write mqtt-packets

Read and write mqtt-packets
sourceraw docstring

packet-filtercljs

(packet-filter matchers)

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}}
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}}
sourceraw docstring

parse-broker-urlcljs

(parse-broker-url url)
(parse-broker-url url {:keys [default-root-topic]})
source

publishcljs

(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).
sourceraw docstring

send-and-await-responsecljs

(send-and-await-response pkt sink source)
(send-and-await-response pkt
                         sink
                         source
                         {:keys [max-wait] :or {max-wait 1000} :as _opts})
sourceraw docstring

start-pingercljs

(start-pinger {stream :stream {keep-alive :keep-alive} :config :as client}
              {:keys [delay] :or {delay 0}})
source

stop-pingercljs

(stop-pinger {pinger :pinger :as client})
source

stream-connectcljs

(stream-connect {{url :ws-url} :config :as client})
source

stream-connected?cljs

(stream-connected? stream)
source

stream-disconnectcljs

(stream-disconnect {:keys [stream] :as client})
source

subscribecljs

(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}
sourceraw docstring

tap-chcljs

(tap-ch from-ch new-ch)
source

timeout-channels-wont-prevent-nodejs-exit!cljs

(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.
sourceraw docstring

topic-filter-matches-topic?cljs

(topic-filter-matches-topic? topic-filter topic)
source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close