Created
August 8, 2011 07:59
-
-
Save t8g/1131377 to your computer and use it in GitHub Desktop.
Petit tests de hook.io
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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