   (websocket-send socket :noop))
 
 
-(def *heartbeat-channel* (permanent-channel))
-(receive-all *heartbeat-channel* (fn [_])) ; all heartbeat messages are volatile
+(def heartbeat-channel (permanent-channel))
+(receive-all heartbeat-channel (fn [_])) ; all heartbeat messages are volatile
 
 (defn heartbeat []
   (log/debug "Bubump")
-  (enqueue *heartbeat-channel* (websocket-message :heartbeat)))
-
-(when (and (.hasRoot (def *heartbeat*))
-           (= Timer (class *heartbeat*)))
-  (.cancel *heartbeat*)) ; sometimes, defonce just doesn't work as-is..
-(def *heartbeat* (new Timer "Engine heartbeat" true))
+  (enqueue heartbeat-channel (websocket-message :heartbeat)))
+
+(when (and (.hasRoot (def heartbeat))
+           (= Timer (class heartbeat)))
+  (.cancel heartbeat)) ; sometimes, defonce just doesn't work as-is..
+(def heartbeat (new Timer "Engine heartbeat" true))
 
 (let [timer-task (proxy [TimerTask] [] ; in such moments, I love clojure for making java bearable
                    (run [] (heartbeat)))]
-  (doto *heartbeat* (.scheduleAtFixedRate timer-task (long 0) (long (* 1000 20)))))
+  (doto heartbeat (.scheduleAtFixedRate timer-task (long 0) (long (* 1000 20)))))
 
 (defn handshake [request]
   (if-let [sid (and (:session request)
                     (-> request :cookies (get "engine") :value))]
     {:status 200 :content-type "text/plain"
-     :body (cl-format nil "~a:~d:~d:~{~a~^,~}" sid *heartbeat-interval* *close-timeout* ["websocket"])}
+     :body (cl-format nil "~a:~d:~d:~{~a~^,~}" sid heartbeat-interval close-timeout ["websocket"])}
     {:status 401}))
 
 (defn deathwatch [channel timeout] 

        lamina.core
        net.cgrand.moustache
        [clojure.pprint :only [cl-format]]
        [clojure.tools.logging :as log])
  (:import [java.lang Long]
           [java.util Timer TimerTask]
           [clojure.lang Keyword PersistentArrayMap]


(defrecord WebsocketChannel [channel endpoint sequencer])

(def close-timeout 25)
(def heartbeat-interval 20)
(def socket-out (io/file "socket.log"))

(def reserved-event-types #{"connect" "disconnect" "message" "ack"})

