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';hatchetauthenticate'' 'demo' 'iYkrswPZVIrUMv';// Watch for 'log' events and run the defined function when it occurshatchetwatch'log'console.log'log' data;;// Watch anotherhatchetwatch'signup'console.log'signup' data;;// You can also stop listening to an eventsetTimeouthatchetunwatch'log';20000;
var hatchet = require'hatchet.io';hatchetauthenticate'' 'demo' 'iYkrswPZVIrUMv';// Warmup begins connection + auth process to server, otherwise it happens on first "send"// which will likely cause that message to be lost. This will be resolved using a buffer// in a later release. But for the moment all messages are volatile - hatchet isn't for mission critical// messages.hatchetwarmup;// Send 'log' event with data every 2 secondssetIntervalvar data =line: 100file: 'ben.txt';hatchetsend'log' data;2000;// Send 'signup' event with data every secondsetIntervalvar data =firstName: 'Frederick'lastName: 'Gustaveerson'created:;hatchetsend'signup' data;1000;
var hatchet = require'hatchet.io';// Enable logginghatchoptions.log = true;
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.
Copyright (c) 2013 Ben Pearson Licensed under the MIT license.