This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-24
Channels
- # announcements (2)
- # babashka (31)
- # beginners (608)
- # cider (60)
- # clj-kondo (22)
- # cljsrn (28)
- # clojure (14)
- # clojure-europe (5)
- # clojure-nl (3)
- # clojure-spec (1)
- # clojure-uk (19)
- # clojurescript (38)
- # conjure (20)
- # cursive (9)
- # data-science (26)
- # datascript (4)
- # datomic (19)
- # duct (4)
- # emacs (8)
- # figwheel-main (5)
- # fulcro (7)
- # helix (15)
- # leiningen (12)
- # malli (2)
- # off-topic (20)
- # overtone (3)
- # pathom (14)
- # pedestal (10)
- # re-frame (2)
- # reitit (13)
- # ring (13)
- # shadow-cljs (18)
- # spacemacs (8)
How are you supposed to get the current user in a websocket connection in pedestal/jetty? Can’t seem to find any reference to the request at all in the connection request
...
::http/container-options {:context-configurator #(ws/add-ws-endpoints % ws-paths)}
...
(def ws-paths
{"/ws" {:on-connect (fn [e]
(let [[sess channel] ((ws/start-ws-connection new-ws-client) e)]
(println "CANT FIND A TOKEN OR ANYTHING HERE" e)
channel
))
:on-text (fn [msg] (log/info :msg (str "A client sent - " msg)))
:on-binary (fn [payload offset length] (log/info :msg "Binary Message!" :bytes payload))
:on-error (fn [t] (log/error :msg "WS Error happened" :exception t))
:on-close (fn [num-code reason-text]
(log/info :msg "WS Closed:" :reason reason-text))}})
There might be something to reference in this code: https://github.com/ptaoussanis/sente
@U1DBQAAMB You can access to the upgrade request via the websocket session object. Check out the Jetty websocket api for details.
Also, I’m trying to make the connection with some query parameters. I want to A:) make the websocket connection for the associated topic and B:) authenticate that the user has access to the topic
this came up before, i haven't tried it but the notes are here https://clojurians-log.clojureverse.org/pedestal/2020-04-09
is the hindol.adhya
suggesting to replace #(ws/add-ws-endpoints % ws-paths)
with ws-listener
? I’ll give that a try.