From 5c0f4ad0f741da6c431cde075ab18dfb3a7880d5 Mon Sep 17 00:00:00 2001 From: Peter Taoussanis Date: Tue, 4 Jul 2023 09:56:25 +0200 Subject: [PATCH] [new] [example] Add example server-side uidport event handlers --- example-project/src/example/server.clj | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/example-project/src/example/server.clj b/example-project/src/example/server.clj index 7fb67be..500bb2d 100644 --- a/example-project/src/example/server.clj +++ b/example-project/src/example/server.clj @@ -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))