 
 ;; Utils ----------------------
 
+(defn send-data!
+  "Wrapper of send! that logs data and encodes JSON."
+  [channel data]
+  ;; TODO: Somehow log the recepient host.
+  (log/debug (merge {:event     ::sent-data
+                     :google-id (get @channel->google-id channel)}
+                    data))
+  (send! channel (json/encode data)))
+
 (defn broadcast-to!
   "Serializes data and sends it to all connections belonging to
   google-id."
   [google-id data]
+  (log/debug (merge {:event     ::broadcasted-data
+                     :google-id google-id}
+                    data))
   (let [str-data (json/encode data)]
     (doseq [channel (get @active-connections google-id)]
       (send! channel str-data))))


(defn send-error!
  [channel message]
  (send! channel (json/encode
                  {:error message})))

(defn send-invalid-args!
  [channel]

(defn dispatch-command!
  "Calls the appropriate timer command."
  [channel command-data]
  (log/debug (merge {:event ::received-data} command-data))
  (if-let [google-id (get @channel->google-id channel)]
    (if-let [command-fn (command-map (get command-data :command))]
      (command-fn channel google-id (dissoc command-data :command))
