Gered
da2b5d94b2
up until now, a single event handler "on-session" could be provided to wrap-browserchannel which would be invoked each time a new client session was created. it was then the application's responsibility to register listeners for close/receive events inside this on-session event handler. this was kind of clunky honestly. basically every application would want to use all of these events, so why not reduce the boilerplate needed? this change makes it so a map of event handlers (:on-open, :on-close and :on-receive) can be passed under wrap-browserchannel's options map (in the key :events). this makes it simpler for an application to set up browserchannel event handlers, and it works in basically the exact same way as the clientside event handler registration works right now |
||
---|---|---|
.. | ||
resources | ||
src/chat_demo | ||
Procfile | ||
project.clj | ||
README.md |
chat-demo for clj-browserchannel
Cross-browser compatible, real-time, bi-directional communication between ClojureScript and Clojure using Google Closure BrowserChannel.
See also: [clj-browserchannel][1] [1]:https://github.com/thegeez/clj-browserchannel
Demo
clj-browserchannel-demo is an example chat application using a server side implementation for BrowserChannel written in Clojure. The server component is for BrowserChannel version 8.
This enables client->server and server->client communication in ClojureScript and Closure web apps, without any javascript dependencies other than the Google Closure library.
The example runs in at least:
- Chrome
- Firefox
- Internet Explorer 5.5+ (!!)
- Android browser
Running
You can either start it up directly from a REPL by simply running:
(-main)
Or you can run it easily from a command line via the included Leiningen alias to build and run everything:
$ lein rundemo
Once the application server is running, you can then open up http://localhost:8080/ in your browser. Open it in multiple browser windows to see the chat communication in action.
At the bottom of the -main
function in chat-demo.server
, you can
comment/uncomment out the different run-
functions to choose which
web server you want to test out the demo with.
About
Written by: Gijs Stuurman / @thegeez / Blog / GitHub
Updated by: Gered King / @geredking / Github
License
Copyright (c) 2012 Gijs Stuurman and released under an MIT license.