Turn any duplex stream into an actor. Built on the the AMP protocol
for opaque binary and javascript argument support.

Actors are similar to traditional RPC however they are isolated units of communication, an actor receives and sends zero or more messages to and from
its peer with bi-directional messaging. Typical RPC is done at the process-level,
meaning in order to work with data coupled with an identifier such as a user id
that the id must be passed each request, whereas an actor may retain this state.

Sending a single request with multiple async responses,
also illustrates how arguments may be primitives, json objects,
or opaque binary such as sending an image over the wire for
resizing, receiving multiple thumbnail blobs and their
respective size:

var net =require('net');

var actorify =require('actorify');

// client

net.createServer(function(sock){

var actor = actorify(sock);

var img =newBuffer('faux data');

actor.on('image thumbnails',function(img, sizes){

console.log('%s byte image -> %s', img.length, sizes.join(', '));

sizes.forEach(function(size){

actor.send('thumb', size,newBuffer('thumb data'));

});

});

}).listen(3000);

// client

setInterval(function(){

var sock = net.connect(3000);

var actor = actorify(sock);

console.log('send image for thumbs');

var img =newBuffer('faux image');

actor.send('image thumbnails', img,['150x150','300x300']);

actor.on('thumb',function(size, img){

console.log('thumb: %s', size);

});

},500);

You may also associate callbacks with an actor message, effectively
turning it into a traditional RPC call: