 (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.:

(sente/start-chsk-router! ch-chsk event-msg-handler*)

(defn test-socket-callback []
  (chsk-send! [:rente/testevent {:message "Hello socket Callback!"}] 2000 #(js/console.log "Callback received: " (pr-str %))))

(defn test-socket-event []
  (chsk-send! [:rente/testevent {:message "Hello socket Event!"}]))


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

(defn event-msg-handler* [{:as ev-msg :keys [id ?data event]}]
  (event-msg-handler ev-msg))

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