Bronson is a real time browser messaging framework with serverside integration.
Bronson shines in three dedicated areas:
- A wide array of supported platforms
- Isolated communication channels (rooms)
- Integration of existing backend APIs into the broadcasting platform.
More details below.
- Desktop web browsers: IE 6+, FF 3+, Safari 3+, Chrome 4+, Opera 10+
- Mobile browsers: iOS Safari, Android WebKit, Android Chrome
- Hybrid mobile applications: PhoneGap, RhoMobile, Sencha, Titanium Appcelerator
- Native mobile applications: iOS (via socket.IO-objc), Android (via java-socket.io.client)
Clients can enter dedicated chat rooms to talk to other clients in that room. The visibility of broadcast messages is restricted to the room that the emitting client is in. Several rooms can be active at a time, allowing for parallel, isolated communication patterns.
Besides the traditional broadcast of static payload directly to peers, Bronson's broadcast messages can include a dynamic backend portion. In this scenario, the Bronson platform first performs a specified request to the backend API for the emitting client, then includes the backend's response into the message broadcasted to all clients.
|Step 1||Clients load from the backend system and set up a persistent connection to the Bronson server.|
|Step 2||A client emits a broadcast message that includes a backend request to the Bronson server.|
|Step 3||The Bronson server forwards the request, including all request headers and cookies, to the backend system.|
|Step 4||The backend system responds to the Bronson server. No traffic to the clients happens at this stage.|
|Step 5||The Bronson server broadcasts the original broadcast message, including the response from the backend, to all clients.|
This is useful, for example, to notify participants in a room about new data objects that have to be created on the server first. Bronson allows to do both things (creating objects in the backend and notifying all other clients) using only one call from the emitting device, thereby saving bandwidth and battery life on it.
Install the NPM module.
$ npm install bronson
Now, create a file called server.coffee, with this content:
Bronson = require 'bronson'bronson = new Bronson "api.my-backend-host.com"bronson.listen 3000
You can start this server like so:
$ coffee server.coffee
More complete usage examples are given in the /examples directory.
The chat directory contains a fully functional chat application. The server portion, chat.coffee, creates a web server that serves an HTML file as well as a Bronson server for real-time broadcasting in only 12 lines of CoffeeScript. The client portion, chat.html, connects to the server, logs into a room, announces the user to the other participants, and provides facilities as well as UI for sending and receiving chat messages in only 10 lines of CoffeeScript.
Fork away and send us a pull request!
$ npm test
You can alternatively run tests automatically with guard: