   "Blocks current thread until all osc messages in action-fn have completed.
   Returns result of action-fn."
   [action-fn]
-  (let [id (update-server-sync-id)
+  (let [id (next-id ::server-sync-id)
         prom (promise)
         key (uuid)]
     (on-event "/synced"

      (log/debug (str "Sending: " path [args])))
    (apply validated-snd @server-osc-peer* path args)))

(defn- update-server-sync-id
  "update osc-sync-id*. Increments by 1 unless it has maxed out
  in which case it resets it to 0."
  []
  (swap! server-sync-id* (fn [cur] (if (= Integer/MAX_VALUE cur)
                                    0
                                    (inc cur)))))

(defn on-server-sync
  "Registers the handler to be executed when all the osc messages generated
   by executing the action-fn have completed. Returns result of action-fn."
  [action-fn handler-fn]
  (let [id (update-server-sync-id)
        key (uuid)]
    (on-event "/synced"
              (fn [msg] (when (= id (first (:args msg)))

  synchronise with its completion. The action-fn can sync using the fn server-sync.
  Returns the result of action-fn."
  [action-fn]
  (let [id (next-id ::server-sync-id)
        prom (promise)
        key (uuid)]
    (on-event "/synced"
