Use root URL for WebSocket connection (because Heroku)
This commit is contained in:
parent
3b7dc67b5f
commit
73d965f8f7
3 changed files with 5 additions and 4 deletions
|
@ -29,7 +29,7 @@
|
|||
(include-js @js-file)]))
|
||||
|
||||
(defroutes routes
|
||||
(GET "/ws" [] ws/websocket-handler)
|
||||
(GET "/" [] ws/websocket-handler)
|
||||
(GET "/" [] (index-page))
|
||||
(GET "*/src/cljs/grub/:file" [file] (resp/file-response file {:root "src/cljs/grub"}))
|
||||
(GET "/js/public/js/:file" [file] (resp/redirect (str "/js/" file)))
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
(httpkit/send! ws-channel (str event))
|
||||
(recur))))
|
||||
|
||||
(defn setup-new-connection [ws-channel]
|
||||
(defn set-up-new-connection [ws-channel]
|
||||
(let [[ws-channel-id client-chan] (add-connected-client! ws-channel)]
|
||||
(println "Client connected:" (.toString ws-channel) (str "(" ws-channel-id ")"))
|
||||
(println (count @connected-clients) "client(s) connected")
|
||||
|
@ -59,7 +59,8 @@
|
|||
(forward-other-events-to-client client-chan ws-channel)))
|
||||
|
||||
(defn websocket-handler [request]
|
||||
(httpkit/with-channel request ws-channel (setup-new-connection ws-channel)))
|
||||
(when (:websocket? request)
|
||||
(httpkit/with-channel request channel (set-up-new-connection channel))))
|
||||
|
||||
(defn get-other-client-channels [my-ws-channel-id]
|
||||
(-> @connected-clients
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
|
||||
(defn get-remote-chan [to-remote]
|
||||
(let [server-url (str "ws://" (.-host (.-location js/document)) "/ws")
|
||||
(let [server-url (str "ws://" (.-host (.-location js/document)))
|
||||
handler (goog.events.EventHandler.)
|
||||
remote-events (chan)]
|
||||
(reset! websocket* (goog.net.WebSocket.))
|
||||
|
|
Loading…
Reference in a new issue