-
-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ping event ids: server-side vs client-side #319
Comments
It is normal for I deal with it like this: (defrecord SenteClientHandler [send! state api handler]
ISenteClientHandler
(unhandled-event [this {:keys [event] :as ev-msg}]
(warnf "Unhandled event: %s" event))
(chsk-handshake-event [this {:keys [send-fn] :as ev-msg}]
(debugf "Handshake"))
(chsk-state-event [this {:keys [?data] :as ev-msg}]
(let [[old new] ?data]
(debugf "Channel socket state change: %s" new)))
(chsk-recv-event [this {:keys [?data] :as ev-msg}]
(let [[cmd data] ?data]
(condp = cmd
:chsk/ws-ping nil
:my/event (handle-my-event this data)
(warnf "Unhandled push event from server: %s" ?data))))
(event-msg-handler [this ev-msg]
#_(debugf "Sente event: %s" ev-msg)
(condp = (:id ev-msg)
:chsk/handshake (chsk-handshake-event this ev-msg)
:chsk/state (chsk-state-event this ev-msg)
:chsk/recv (chsk-recv-event this ev-msg)
(unhandled-event this ev-msg)))
component/Lifecycle
(start [this]
(infof "Starting")
(assoc this :handler (partial event-msg-handler this)))
(stop [this]
(infof "Stopping")
(dissoc this :handler))) |
Oh, ok. I'm glad to learn that it's not just me.
So should this github issue result in a change to the documentation? Or a change to the implementation (which would seem to be a breaking change)? |
Also note that the Here is the relevant lines in the source: Here is an earlier issue that discusses this: And slightly more info in comments in the commit that added this than currently exists in the code now: |
Is ping the only standard event that will get wrapped in recv? |
Also, out of curiosity, why is |
@SVMBrown Your questions are addressed by the comment above by @jjttjj (thanks Justin!). Default val is currently Leaving this issue open for now as a reminder to change the default in a future release. |
Closing since the default will be changed in forthcoming v1.18 👍 |
I found Sente via pragprog's Web Development with Clojure (2ed). Great library! While updating the book project from sente-1.8.0 to 1.12.0, I hit a situation that lead to a question about pings.
Updating the version broke the book's project client-side event handling because of pings. Based on the doc, I expected the ping events to have
:id :chsk/ws-ping
:On the server side, I see this is so:
But on the client side, the events have
:id :chsk/recv
, instead. And deeper inside the event map, I see:chsk/ws-ping
:Am I doing something wrong that would make the ping events have
:id :chsk/recv
instead of:id :chsk/ws-ping
? Right now, the clojurescript:chsk/recv
handling includes logic to identify and ignore ping events.The text was updated successfully, but these errors were encountered: