-
Notifications
You must be signed in to change notification settings - Fork 5
Quick start
jacobgroundwater edited this page Feb 3, 2013
·
2 revisions
$ npm install federation
// Boilerplate
var fed = require('federation');
var dir = fed.init().director;
// Create Some Actors
var bob = dir.createActor('bob');
var tom = dir.createActor('tom');
// Assign Behaviours
bob.onMessage = function(msg){
console.log('Bob Got Message: %s',msg);
}
tom.onMessage = function(msg){
console.log('Tom Got Message: %s',msg);
}
// Start Messaging!
bob.tell('tom','hi');
tom.tell('bob','bye');
// Boilerplate
var fed = require('federation');
var dir = fed.init().director;
// Create Some Actors
var bob = dir.createActor('bob');
var tom = dir.createActor('tom');
// Assign Behaviours
bob.onMessage = function(msg,reply){
reply('My name is Bob.');
}
// Ask Away
tom.ask('bob','what is your name?',function(err,reply){
if(err) return console.error('Error asking Bob:',err);
console.log('Got Reply:',reply);
});