Closed njerig closed 2 years ago
I have the following event router definition on my client:
(defn event-msg-handler [{:as ev-msg :keys [id ?data event]}] (-event-msg-handler ev-msg)) (defmethod -event-msg-handler :default [{:as ev-msg :keys [event]}] (js/console.log "Unhandled event: %s" (str event))) (defmethod -event-msg-handler :chsk/recv [{:as ev-msg :keys [?data]}] (js/console.log "Push event from server: %s" (str ?data))) (defmethod -event-msg-handler :api/token [{:as ev-msg :keys [?data]}] (js/console.log "Received token from backend") (cookies/set! :token ?data {:max-age 3600 :secure? true :raw? true}))
My event router on my server is exactly the same, except for the :api/token defmethod, which is this:
:api/token
(defmethod -event-msg-handler :api/token [{:as ev-msg :keys [?data ring-req]}] (let [uid (:uid (:session ring-req)) status (:status ?data)] (when (= status :expired) (lm/refresh-token :spotify)) (chsk-send! uid [:api/token (lm/oauth-token :spotify)])))
On the index page, I send {:status :ready} from client to server on the :api/token channel. I expected that, on reply from the server, my client :api/token method would be called. Instead, only the :chsk/recv method is called. Is this a bug?
{:status :ready}
:chsk/recv
@njerig Hi Njeri, please see the :wrap-recv-evs? config option
:wrap-recv-evs?
I have the following event router definition on my client:
My event router on my server is exactly the same, except for the
:api/token
defmethod, which is this:On the index page, I send
{:status :ready}
from client to server on the:api/token
channel. I expected that, on reply from the server, my client:api/token
method would be called. Instead, only the:chsk/recv
method is called. Is this a bug?