2012-04-07 15:08:23 -04:00
# clj-browserchannel
2012-04-07 15:06:21 -04:00
Cross-browser compatible, real-time, bi-directional
communication between ClojureScript and Clojure using Google Closure
BrowserChannel.
2016-05-16 19:05:20 -04:00
From the [Google Closure API][1]:
2012-04-07 15:06:21 -04:00
2016-05-16 19:05:20 -04:00
> A BrowserChannel simulates a bidirectional socket over HTTP.
> It is the basis of the Gmail Chat IM connections to the server.
The JavaScript API of BrowserChannel is open-source and part of the
2012-04-07 15:06:21 -04:00
Google Closure library. The server component is not, as is noted in
the Google Closure book ("Closure: The Definitive Guide by Michael Bolin").
2016-05-16 18:56:52 -04:00
[1]: https://google.github.io/closure-library/api/source/closure/goog/net/browserchannel.js.src.html
2012-04-07 15:06:21 -04:00
2016-05-16 18:56:52 -04:00
## Usage
2012-04-07 15:06:21 -04:00
2016-05-16 19:05:20 -04:00
This project is comprised of multiple libraries. You'll need to include
two of them in your projects.
2016-05-16 18:56:52 -04:00
[clj-browserchannel][2] is the main library containing both the server- and
client-side functionality you'll use in your web apps.
2012-04-07 15:06:21 -04:00
2016-05-16 18:56:52 -04:00
In order to use the server implementation of BrowserChannel you'll need to
2016-05-16 19:05:20 -04:00
use one of the async adapters. Currently the provided options are:
2012-04-07 15:06:21 -04:00
2016-05-16 18:56:52 -04:00
* [clj-browserchannel-jetty-adapter][3]
* [clj-browserchannel-immutant-adapter][4]
2012-04-07 15:06:21 -04:00
2016-05-16 18:56:52 -04:00
[2]: https://github.com/gered/clj-browserchannel/tree/master/clj-browserchannel
[3]: https://github.com/gered/clj-browserchannel/tree/master/clj-browserchannel-jetty-adapter
[4]: https://github.com/gered/clj-browserchannel/tree/master/clj-browserchannel-immutant-adapter
2012-04-07 15:06:21 -04:00
2016-05-16 18:56:52 -04:00
You can find more information on usage of all of these components by
following any of the above links to them.
2012-04-07 15:06:21 -04:00
2016-05-16 18:56:52 -04:00
## Demo
2012-04-07 15:06:21 -04:00
2016-05-16 19:05:20 -04:00
The [chat-demo][5] application is an example chat application using a
2016-05-16 18:56:52 -04:00
client-side and server-side implementation for BrowserChannel written in
Clojure/ClojureScript. The server component is for BrowserChannel version 8.
2016-05-16 19:05:20 -04:00
The client component serves as a wrapper over `goog.net.BrowserChannel`
which also currently implements version 8 of the protocol.
2012-04-07 15:06:21 -04:00
2016-05-16 19:05:20 -04:00
[5]: https://github.com/gered/clj-browserchannel/tree/master/chat-demo
2012-04-07 15:06:21 -04:00
2016-05-16 18:56:52 -04:00
The chat-demo web app runs in at least:
2012-04-07 15:06:21 -04:00
2016-05-16 18:56:52 -04:00
* Chrome
* Firefox
* Internet Explorer 5.5+ (!!)
* Android browser
2016-05-16 19:05:20 -04:00
* Others
2012-04-07 15:06:21 -04:00
## Related and alternative frameworks
* Websockets - Websockets solve the same problems as BrowserChannel,
however BrowserChannel works on almost all existing clients.
2016-05-16 19:05:20 -04:00
Websockets ultimately replaces BrowserChannel.
* socket.io - [socket.io][6] provides a similar api as BrowserChannel on
2016-05-16 18:56:52 -04:00
top of many transport protocols, including websockets. BrowserChannel
only has two transport protocols: XHR and forever frames (for IE) in
streaming and non-streaming mode.
2012-04-07 15:06:21 -04:00
2016-05-16 19:05:20 -04:00
[6]: http://socket.io
2012-04-07 15:06:21 -04:00
## Other BrowserChannel implementations
Many thanks to these authors, their work is the only open-source
documentation on the BrowserChannel protocol.
* [libevent-browserchannel-server][libevent]
2016-05-16 19:05:20 -04:00
in C++ by Andy Hochhaus - Has the most extensive documentation on the BrowserChannel protocol (dead project?). See the protocol documentation on [archive.org][libevent-doc].
* [browserchannel][ruby] in Ruby by David Turnbull (dead project?)
2012-04-07 15:06:21 -04:00
* [node-browserchannel][node]
in Node.js/Javascript by Joseph Gentle
[libevent]: http://code.google.com/p/libevent-browserchannel-server
2016-05-16 18:56:52 -04:00
[libevent-doc]: http://web.archive.org/web/20121226064550/http://code.google.com/p/libevent-browserchannel-server/wiki/BrowserChannelProtocol
2012-04-07 15:06:21 -04:00
[ruby]: https://github.com/dturnbull/browserchannel
[node]: https://github.com/josephg/node-browserchannel
## About
Written by:
2016-05-16 18:56:52 -04:00
Gijs Stuurman /
[@thegeez ](http://twitter.com/thegeez ) /
[Blog ](http://thegeez.github.com ) /
[GitHub ](https://github.com/thegeez )
Many updates in this fork by:
Gered King /
[@geredking ](http://twitter.com/geredking ) /
[GitHub ](https://github.com/gered )
2012-04-07 15:06:21 -04:00
### License
Copyright (c) 2012 Gijs Stuurman and released under an MIT license.