This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-08
Channels
- # babashka (18)
- # beginners (35)
- # biff (15)
- # cider (24)
- # clj-commons (26)
- # clj-kondo (12)
- # clojure (18)
- # clojure-austin (1)
- # clojure-dev (2)
- # clojure-europe (15)
- # clojure-losangeles (1)
- # clojure-nl (1)
- # clojure-norway (88)
- # clojure-seattle (2)
- # clojure-spec (14)
- # clojure-uk (27)
- # clojuredesign-podcast (5)
- # clojurescript (25)
- # cursive (3)
- # datahike (26)
- # datalevin (13)
- # datomic (39)
- # etaoin (19)
- # events (1)
- # fulcro (12)
- # graphql (1)
- # hyperfiddle (40)
- # introduce-yourself (3)
- # joyride (8)
- # lsp (53)
- # missionary (7)
- # nyc (1)
- # off-topic (31)
- # overtone (10)
- # reitit (6)
- # shadow-cljs (9)
- # slack-help (9)
- # thejaloniki (1)
- # tools-deps (12)
One needs to dig into fulcro-websockets code to figure out that for a push handler such as:
(fws/fulcro-websocket-remote {:csrf-token token :push-handler push-handler})
the server must use the topic :api/server-push:
((:send-fn websockets) 6421 [:api/server-push :lasagna])
(defstate websockets
:start
(fws/start! (fws/make-websockets
query-parser
{:http-server-adapter (get-sch-adapter)
:parser-accepts-env? true
;; See Sente for CSRF instructions. If you are using ring-defaults,
;; you will likely want {:csrf-token-fn :anti-forgery-token} here.
:sente-options {:csrf-token-fn nil}})))
and then you can use the protocols directly on websockets
as the this
.indeed thanks, although it should be (.push websockets cid :x {:value 1})
not (push websockets cid :x {:value 1})
right? I think that's the bit that confused me last time, was late and I haven't used a protocol for a year so I forgot about the .
and since it wasn't there on the doc either I didn't manage to use push
True, not sure why .push works and not push for me
brian.server-components.websockets> (push websockets 6421 :test {:type :topic-description :subject/id 481})
Syntax error compiling at (*cider-repl ~/brian:localhost:7888(clj)*:23279:37).
Unable to resolve symbol: push in this context
2023-11-09T16:53:11.953Z project2501 DEBUG [taoensso.sente:803] - [ws/on-msg] Server will auto-reply to ping from u_6421/c_d5b25c/n_9948cc
brian.server-components.websockets> (.push websockets 6421 :test {:type :topic-description :subject/id 481})
nil2023-11-09T16:53:14.949
protocols declare function-like names within their namespace…again, not OOP interop. The .push is leveraging the fact that the protocol is being implemented by deftype, which does generate a class. Using the OOP interop means you’re actually kind of ignoring the protocol…for example, extend
would not work with the interop
Yeah I tried with fulcro.networking.websocket, didn't realize the protocol was defined in com.fulcrologic.fulcro.networking.websocket-protocols
WDYT about https://github.com/fulcrologic/fulcro-websockets/pull/9/files ? One thing I’d like to understand is what is the verb
(in the examples :x
) in this context.
Depends how you want to use the ws. I for instance didn’t really tried to understand how to get my Authn/authz work for using it as the main remote for pathom queries so it’s just there for server pushes. I have a case on the client Based on :x it let’s me know what to do with the message