 (ns rente.client.ws
   (:require [taoensso.sente :as sente]
             [taoensso.sente.packers.transit :as sente-transit]))
+
+(defmulti push-msg-handler (fn [[id _]] id)) ; Dispatch on event key which is 1st elem in vector
+
+(defmethod push-msg-handler :rente/testevent
+  [[_ event]]
+  (js/console.log "PUSHed :rente/testevent from server: %s " (pr-str event)))
 
 (defmulti event-msg-handler :id) ; Dispatch on event-id
 ;; Wrap for logging, catching, etc.:


(defmethod event-msg-handler :chsk/recv
  [{:as ev-msg :keys [?data]}]
  (js/console.log "Push event from server: %s" (pr-str ?data)))

(defn event-msg-handler* [{:as ev-msg :keys [id ?data event]}]
  ;(js/console.log "Event: %s" (pr-str event))
  (event-msg-handler ev-msg))

(let [packer (sente-transit/get-flexi-packer :edn)

(defmethod event-msg-handler :default ; Fallback
    [{:as ev-msg :keys [event]}]
    (js/console.log "Unhandled event: %s" (pr-str event)))

(defmethod event-msg-handler :chsk/state
  [{:as ev-msg :keys [?data]}]
