 
 (def clients (atom {}))
 
+(defstruct msgbuff :msg :count)
+
+(def msg_handler (agent (struct msgbuff "" 0)))
+
+; append message, increment count
+(defn send_message[c msg] 
+  {:msg (str (:msg c) msg) :count (inc (:count c))}
+)
+
+
 (defn ws [req]
   (with-channel req con 
     (swap! clients assoc con true)

(future (loop []
          (doseq [client @clients]
            (println "sending message to client...")
            (send! (key client) (generate-string
                                  {:happiness (rand 10)})
                   false))
          (Thread/sleep 5000)
          (recur)))

               (or (System/getenv "PORT") "8080"))]
    (run-server application {:port port :join? false})))



