Server push of data from Clojure to ClojureScript
clojure, clojurescript, core.async, push-notification, web-services
Solution
I prefer to use aleph, here is the wiki, you can simply use `wrap-ring-handler` function to wrap existed handlers.
For the 'push' function, most useful part is aleph's async handler. It builds on top of netty, not a one connection one thread model, so the server side do not need worry about the tcp connection count.
Some implement details:
- Server side use aysnc handler, hold all the client connections (channels)
- In 60(for example) seconds, if there is no 'new data', send an empty response
- if server side has a response ,send it.
- The client side can simply send a normal http request to the server
- when the client get the response, handle the response body, and then, re-send a http request again
- please check the client and all the proxy servers to set the correct timeout value
There are more ways here : http://en.wikipedia.org/wiki/Push_technology
Problem
I'm writing an application server in Clojure that will use ClojureScript on the client. I'd like to find an efficient, idiomatic way to push data from the server to the client as realtime events, ideally using a some combination of: - http-kit - core.async - Ring (But I'm open to other possibilities) Can anyone provide a good example / approach to doing this?