generated from FiV0/clj-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsocket.clj
22 lines (19 loc) · 978 Bytes
/
socket.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(ns io.dbme.socket
(:require [taoensso.sente :as sente]
[taoensso.sente.server-adapters.http-kit :as http-kit]
[taoensso.sente.packers.transit :as sente-transit]))
(let [chsk-server (sente/make-channel-socket-server! (http-kit/get-sch-adapter)
{:packer (sente-transit/get-transit-packer)
:csrf-token-fn nil})
{:keys [ch-recv send-fn connected-uids ajax-post-fn ajax-get-or-ws-handshake-fn]} chsk-server]
(def ring-ajax-post ajax-post-fn)
(def ring-ajax-get-or-ws-handshake ajax-get-or-ws-handshake-fn)
(def ch-chsk ch-recv)
(def chsk-send! send-fn)
(def connected-uids connected-uids))
(defn send-data [data]
(doseq [uid (:any @connected-uids)]
(chsk-send! uid
[:some/broadcast data])))
(comment
(send-data {:some-new-data true}))