Skip to content

Instantly share code, notes, and snippets.

@rodnaph
Created October 28, 2012 11:30
Show Gist options
  • Save rodnaph/3968384 to your computer and use it in GitHub Desktop.
Save rodnaph/3968384 to your computer and use it in GitHub Desktop.
Simple Aleph websocket
;; src/myapp/core.clj
(ns myapp.core
(:use lamina.core
aleph.http))
(def ws-channel (channel))
(defn app [ch _]
(receive ch
(fn [_]
(siphon ws-channel ch))))
(defn send-message [msg]
(enqueue ws-channel msg))
(start-http-server app {:port 1234 :websocket true})
;; src/myapp/another.clj
; You can then send messages to connected peerrs
(send-message "foo")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment