This repository has been archived on 2023-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
clj-browserchannel/chat-demo
Gered 6674d171c3 update client & server send fn's to allow sending even non-map data
i personally think this was an important change as the default encoding
of maps to be sent as json is somewhat lossy (keywords converted to
strings, would never be able to get this 100% perfect using json alone
without a more complex encoding solution). encoding to edn is the
perfect solution to this.

since browserchannel pretty much requires the final sent data to be
json encoded, we just serialize the clojure data being sent to an
edn string within a root json object.

this does ultimately mean we have to do a little bit of pre-parsing
of sent and received maps to encode/decode properly and make it
completely transparent to application code, but i think it's an
acceptable tradeoff.
2016-05-09 12:45:17 -04:00
..
resources update chat-demo to use an anti-forgery token to demo how to set it up 2016-05-08 17:59:31 -04:00
src/chat_demo update client & server send fn's to allow sending even non-map data 2016-05-09 12:45:17 -04:00
Procfile fix chat-demo 2016-05-07 16:20:54 -04:00
project.clj rename clj-browserchannel-server as it now also includes cljs stuff 2016-05-08 18:00:42 -04:00
README.md add immutant adapter support to the chat-demo 2016-05-07 16:58:36 -04:00

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.