Skip to content

Instantly share code, notes, and snippets.

@ul
Last active August 29, 2015 14:04
Show Gist options
  • Save ul/c6aa280cc990acf423de to your computer and use it in GitHub Desktop.
Save ul/c6aa280cc990acf423de to your computer and use it in GitHub Desktop.
SOwS1
(ns app.core
(:require [clojure.core.async :as async :refer [go-loop]]
[compojure.core :refer [routes GET POST]]
[compojure.route :as route]
[taoensso.sente :as sente]
;; ...
))
;;;; ...
(let [{:keys [ch-recv send-fn ajax-post-fn ajax-get-or-ws-handshake-fn
connected-uids]}
(sente/make-channel-socket! {})]
(def ring-ajax-post ajax-post-fn)
(def ring-ajax-get-or-ws-handshake ajax-get-or-ws-handshake-fn)
(def ch-chsk ch-recv) ; ChannelSocket's receive channel
(def chsk-send! send-fn) ; ChannelSocket's send API fn
(def connected-uids connected-uids)) ; Watchable, read-only atom
(defn app-routes []
(routes
(GET "/" [] index)
(GET "/chsk" req (ring-ajax-get-or-ws-handshake req))
(POST "/chsk" req (ring-ajax-post req))
(route/resources "/")
(route/not-found "Not Found")))
;;;; ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment