Pass message to parent

This commit is contained in:
niten 2023-03-18 12:54:11 -07:00
parent 16dd4b1440
commit 8f71590fd8
1 changed files with 8 additions and 6 deletions

View File

@ -74,7 +74,7 @@
(defrecord MilquetoastJsonClient [client] (defrecord MilquetoastJsonClient [client]
IMilquetoastClient IMilquetoastClient
(send-message! [_ topic msg opts] (send-message! [_ topic msg opts]
(.publish client topic (create-message (json/write-str msg) opts))) (send-message! client topic (json/write-str msg) opts))
(stop! [_] (stop! client)) (stop! [_] (stop! client))
(add-channel! [_ chan] (add-channel! client chan)) (add-channel! [_ chan] (add-channel! client chan))
(subscribe-topic! [_ topic opts] (subscribe-topic! [_ topic opts]
@ -102,11 +102,13 @@
:or {buffer-size 1}}] :or {buffer-size 1}}]
(subscribe-topic! client topic {:buffer-size buffer-size})) (subscribe-topic! client topic {:buffer-size buffer-size}))
(defn connect! [& {:keys [broker-uri username password verbose] (defn connect! [& {:keys [host port scheme username password verbose]
:or {verbose false}}] :or {verbose false
(MilquetoastClient. (create-mqtt-client! broker-uri username password) scheme :tcp}}]
(atom []) (let [broker-uri (str (name scheme) "://" host ":" port)]
verbose)) (MilquetoastClient. (create-mqtt-client! broker-uri username password)
(atom [])
verbose)))
(defn connect-json! [& args] (defn connect-json! [& args]
(MilquetoastJsonClient. (apply connect! args))) (MilquetoastJsonClient. (apply connect! args)))