Skip to content

Instantly share code, notes, and snippets.

@t8g
Created August 8, 2011 07:59
Show Gist options
  • Save t8g/1131377 to your computer and use it in GitHub Desktop.
Save t8g/1131377 to your computer and use it in GitHub Desktop.
Petit tests de hook.io
/* FILE 1 */
/* Le serveur qui écoute (à lancer en premier) */
var Hook = require('hook.io').Hook,
util = require('util');
var instance = new Hook({ name: 'server', debug: true});
instance.on('hook::listening', function(data){
//console.log('LISTENING');
//console.log(instance.defaults['hook-host']);
});
instance.on('*::hello', function(data){
console.log(data);
});
instance.listen({});
/* FILE 2 */
/* Le client qui parle (à lancer en second) */
var Hook = require('hook.io').Hook,
util = require('util');
var S = function(options){
var self = this;
Hook.call(self, options);
self.on('hook::ready', function(){
setInterval(function () {
self.emit('hello', 'Hello');
}, 1000);
});
};
util.inherits(S, Hook);
var s = new S({
debug: true,
name: 'client'
});
s.start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment