EventSource HQ module for node.js
Node.js module for EventSource HQ services.
$ npm install eshq-js --save
--save automatically writes to your
package.json file, tell your friends)
node app.js from
examples and open
localhost:3000 to see a working example.
Just remember to change 'key' and 'secret' to your own keys
Given a channel,
var app = require'express'eshq = require'eshq-js'key : "key"secret : "secret"listenapp//now you can use this methodseshqopenchannel: "some-channel"console.log"channel is ready"eshqsendchannel: "some-channel" // Requireddata : "your message" // Requiredname : "notification" // optionalid : "event-id" // optionalconsole.log"message is delivered"applisten3000;
And a layout,
You get the following result:
HTTP/1.1 200 OK Content-Type: text/event-stream id: event-id event: notification data: your message
EventSource HQ is hosted on EC2 and built for performance and scalability. Any Server Sent events implementation requires handling thousands of concurrent open connections. Traditional web servers are not built for this. EventSource HQ takes all the pain away from having to install, configure and manage a parallel infrastructure.
The EventSource HQ client library takes care of all cross-browser support issues. Firefox, Chrome, Safari, Opera and Safari Mobile all support EventSource out of the box. For Internet Explorer, Webkit for Android and older browsers EventSource HQ handles all the tricky fallbacks for you. Just send events and we'll get them to your users.
The software behind EventSource HQ is being developed as a fully open-source project. The core of EventSource HQ is the Haskell based "EventSource Broker" that bridges between the message exchange RabbitMQ and EventSource. All source code is available on Github and you can always move to a self-hosted install if you prefer administrating your own infrastructure.
To run the test suite first invoke the following command within the repo, installing the development dependencies:
$ npm install -d
Change the keys on
then run the tests:
$ npm test
This library is a fork from Mathias Biilmann ruby-gem library, and the partial function remains relatively untouched from there. Mathias is still updating his library and We will try to maintain this one up-to-date.
The port syntax comes from Tcha-Tcho
(The MIT License)
Copyright (c) 2012 Mathias Biilmann <firstname.lastname@example.org> Copyright (c) 2012 Tcha-Tcho <email@example.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.