/README.md
Markdown | 88 lines | 64 code | 24 blank | 0 comment | 0 complexity | 201100e17e3dd3e8ed3cf54fe4d32403 MD5 | raw file
1EvenSource Broker 2================= 3 4A simple bridge between EventSource and an AMQP fanout exchange. 5 6EventSource is a new browser standard released as part of the HTML5 7spec. 8 9It lets the browser send a never-ending HTTP request to a server and 10provides a javascript API for binding to events pushed from the server. 11 12EventSource is very handy when you don't need the full bidirectional 13communication that Websockets offers. it plays well with load-balancers, 14intermediary proxies and HTTPS termination. 15 16This library sets up an EventSource that clients can connect to 17specifying a channel to listen to in the query string. The server 18connects to a fanout AMQP exchange and routes AMQP messages as events to 19the javascript clients. 20 21MongoDB is used to store user and connection information. 22 23The server expects the AMQP messages to be JSON following the format: 24 25 { 26 "channel": "some-channel", // Required 27 "data": "{/"msg/": /"data/"}", // Required 28 "id": "event-id", // optional 29 "name": "event-name" // optional 30 } 31 32To open connections to a channel a user with an key and a secret is 33expected to exist in the database. Before opening a connection a socket 34id must be aquired from by calling POST /socket 35 36A simple example of how to interact with this API can be found in the 37[https://github.com/eshq/eshq-gem](eshq ruby gem). 38 39Installation 40============ 41 42Clone the repository, cd to the root of it and execute 43 44 cabal install 45 46Run as: 47 48 eventsource-broker -p <port> 49 50The broker will look for an AMQP_URL environment variable for a broker 51to connect to. It also takes a MONGO_URL for configuring the database 52connection and an ORIGIN variable that should be a url the server runs 53on for cross domain requests. 54 55License 56======= 57 58Copyright (c)2011, Mathias Biilmann <info@mathias-biilmann.net> 59 60All rights reserved. 61 62Redistribution and use in source and binary forms, with or without 63modification, are permitted provided that the following conditions are met: 64 65 * Redistributions of source code must retain the above copyright 66 notice, this list of conditions and the following disclaimer. 67 68 * Redistributions in binary form must reproduce the above 69 copyright notice, this list of conditions and the following 70 disclaimer in the documentation and/or other materials provided 71 with the distribution. 72 73 * Neither the name of Mathias Biilman <info@mathias-biilmann.net> 74 nor the names of other contributors may be used to endorse or 75 promote products derived from this software without specific prior 76 written permission. 77 78THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 79"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 80LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 81A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 82OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 83SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 84LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 85DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 86THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 87(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 88OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE