Created
November 22, 2010 19:07
-
-
Save swannodette/710453 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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