A dead simple service for pushing events to a web browser.
brew install leiningen
lein run
var h = new Hermes({ server: 'ws://localhost:2959' });
h.subscribe('jazzhands', function(e){
// Do something with the payload...
console.log(e.data)
})
Hermes takes an optional namespace
parameter at instantiation time:
var ninjudd = new Hermes({ server: 'ws://localhost:2959', namespace: 'ninjudd:' });
ninjudd.subscribe('alert', function(e){
// Alerts for ninjudd
})
var gonzo = new Hermes({ server: 'ws://localhost:2959', namespace: 'gonzo:' });
gonzo.subscribe('message', function(e){
// Messages for gonzo
})
To bypass namespacing once added, set the second argument of subscribe
to true:
var namespaced = new Hermes({ server: 'ws://localhost:2959', namespace: 'ninjudd:' });
namespace.subscribe('alert', true, function(e){
// All alerts
})
curl -v -H "Content-Type: application/json" -X PUT -d '{"num":1}' 'localhost:2960/inbox-count'
- Start up your hermes server:
lein run
- In root of the Hermes repo, fire up a little server to serve our example files:
python -m SimpleHTTPServer
- Point your browser to
http://localhost:8000/examples/
- Send an event:
curl -v -H "Content-Type: application/json" -X PUT -d '{"num":1}' 'localhost:2960/inbox-count
A note on using the Flash polyfill for Websockets.
Distributed under the Eclipse Public License, the same as Clojure.