Fork me on GitHub
#immutant
<
2016-06-07
>
renan14:06:39

@tcrawley: Yes, but I did not make the 'broadcast' in sente .... 😞

tcrawley17:06:09

@renan: you could keep a global atom of {user ws-connection} that you update from :on-open/:on-close, and then send! to each value in that map. would that work?

andreas-thoelke21:06:21

@renan this will do the trick:

andreas-thoelke21:06:08

(def websocket-callbacks
  {:on-open    connect!
   :on-message notify-clients!})

(defonce channels (atom #{}))

(defn connect! [channel]
  (swap! channels conj channel))

(defn notify-clients! [_ msg]
  (doseq [channel @channels]
    (async/send! channel msg)))