Skip to content

Commit

Permalink
[new] [example] Add example server-side uidport event handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
ptaoussanis committed Jul 4, 2023
1 parent ad62f1e commit 5c0f4ad
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions example-project/src/example/server.clj
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,22 @@
(when ?reply-fn
(?reply-fn {:unmatched-event-as-echoed-from-server event}))))

(defmethod -event-msg-handler :chsk/uidport-open
[{:as ev-msg :keys [ring-req]}]
(let [session (:session ring-req)
uid (:uid session)]
(if uid
(timbre/infof "User connected: user-id `%s`" uid)
(timbre/infof "User connected: no user-id (user didn't have login session)"))))

(defmethod -event-msg-handler :chsk/uidport-close
[{:as ev-msg :keys [ring-req]}]
(let [session (:session ring-req)
uid (:uid session)]
(if uid
(timbre/infof "User diconnected: user-id `%s`" uid)
(timbre/infof "User diconnected: no user-id (user didn't have login session)"))))

(defmethod -event-msg-handler :example/test-rapid-push
[ev-msg] (test-fast-server>user-pushes))

Expand Down

0 comments on commit 5c0f4ad

Please sign in to comment.