1.0.1 • Published 9 years ago
lestia v1.0.1
Lestia
Lestia is a library of Message-based RPC that can do callback.
What's this ?
Lestia is a library of Message-based RPC. It use JSON as function arguments serialized. It can pass function and can do callback!!
Get started
$ npm install lestia --save
Tests
$ npm install
$ npm test
References
Create new RPC client
var lestia = require('lestia');
var client = lestia();
Set message handler
client.on('send', function (msg) {
// Send message code
SomeMessageAPI.send(msg);
});
// Receive message code
SomeMessageAPI.addListener('receive', function (msg) {
client.emit('receive', msg);
});
Get RPC function
var func = client.get('function_name');
func('arg1', [ 1, 2, 3 ]);
Set RPC function
client.set('function_name', function (arg1, arg2) {
// Called by remote
});
Log and Error message handling
client.on('error', function (err) {
console.error(err);
});
client.on('log', function (log) {
console.log(log);
});
License
MIT License