Created
January 15, 2013 23:59
-
-
Save seralf/4543350 to your computer and use it in GitHub Desktop.
PingPong Actor with node.js and 'drama' module (inspired by akka)
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
var drama = require('drama') | |
var sys = drama('sys') | |
var Spider = function() { | |
var i = 0 | |
var me = this.self.pick('ping', 'pong', 'end') | |
return { | |
ping : function() { | |
console.log('PING') | |
if (++i > 10) { | |
me.end() | |
} else { | |
me.pong() | |
} | |
}, | |
pong : function() { | |
console.log('\tPONG') | |
me.ping() | |
}, | |
end : function() { | |
console.log('---- END ----') | |
} | |
} | |
} | |
var pingPong = sys.actor('PING-PONG', Spider).init().pick('ping') | |
pingPong.ping() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment