Skip to content

amalloy/hermes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hermes

A dead simple service for pushing events to a web browser.

Usage - Server

brew install leiningen
lein run

Usage - Client

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
})

Sending events

curl -v -H "Content-Type: application/json" -X PUT -d '{"num":1}' 'localhost:2960/inbox-count'

Examples

  1. Start up your hermes server: lein run
  2. In root of the Hermes repo, fire up a little server to serve our example files:
python -m SimpleHTTPServer
  1. Point your browser to http://localhost:8000/examples/
  2. Send an event: curl -v -H "Content-Type: application/json" -X PUT -d '{"num":1}' 'localhost:2960/inbox-count

Websockets Polyfill

A note on using the Flash polyfill for Websockets.

License

Distributed under the Eclipse Public License, the same as Clojure.

About

Push notifications for your browser.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •