mar
Version:
MAR - Message & Reply, is a RPC library based on message exchange.
14 lines (10 loc) • 342 B
JavaScript
var Server = require('..').Server;
var s = new Server(8081);
s.on('ping', function(msg) {
console.log('ping sent at [%s]', new Date(msg.data));
if (msg.reply) msg.reply(null, new Date().getTime());
});
s.on('mar.auth', function(msg) {
if (msg.data != 'foobar') return msg.reply('auth denied');
msg.reply(null, 'auth granted');
});