Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created November 22, 2010 19:07
Show Gist options
  • Save swannodette/710453 to your computer and use it in GitHub Desktop.
Save swannodette/710453 to your computer and use it in GitHub Desktop.
(ns ninth-post.websocket
(:use [aleph.http core server]
lamina.core)
(:require [clj-json.core :as json]))
(def square (ref {:x 100 :y 100}))
(def broadcast-channel (channel))
(defn handler [ch handshake]
(siphon ch broadcast-channel)
(siphon broadcast-channel ch)
(enqueue ch (json/generate-string {:square @square})))
(start-http-server #'handler {:port 9000 :websocket true})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment