Hosted socket.io service with a simple API for sending and receiving messages.
Hosted (or self-hosted) socket.io service with a simple API for sending and receiving messages. It can be used for logging, analytics or any simple message broadcasting for your app.
Install the module with:
npm install hatchet.io
var hatchet = require'hatchet.io';var consumer = hatchetconsumer'demo' 'I6mMbTSOq4rCdM' log: true ;// Watch for 'log' events and run the defined function when it occursconsumerwatch'log'console.log'log' data;;// Watch anotherconsumerwatch'signup'console.log'signup' data;;// You can also stop listening to an eventsetTimeoutconsumerunwatch'log';20000;
var hatchet = require'hatchet.io';var contributor = hatchetcontributor'demo' 'iYkrswPZVIrUMv' log: true ;// Send 'log' event with data every 2 secondssetIntervalvar data =line: 100file: 'ben.txt';contributorsend'log' data;2000;// Send 'signup' event with data every secondsetIntervalvar data =firstName: 'Frederick'lastName: 'Gustaveerson'created:;contributorsend'signup' data;1000;
log: false // when enabled it will console.log out hatchet related log messages
Please feel free to contribute. If you see any areas for improvement, particularly in regards to performance / reliability it'd be great to receive your pull requests / comments because it's really the main crux of the application.
require('hatchet.io'). Previously you could only have one connection.
Copyright (c) 2013 Ben Pearson Licensed under the MIT license.