rpc-prototype
v2.0.1
Published
Another RPC Implementation
Downloads
1
Maintainers
Readme
Another RPC Implementation
API Documentation
Example
const rpt = require("rpc-prototype")
let alice = new rpt.RPC();
let bob = new rpt.RPC();
alice.pipe(bob).pipe(alice);
alice.then(result => {
console.log('Alice:', result);
});
bob.then(result => {
console.log('Bob:', result);
});
alice.on('ping', (resolve, reject, data) => {
console.log('Alice:', data);
resolve(data); // Sends response with 'Hello World!'
});
bob.exec('ping', 'Hello World!').then(result => {
console.log('Bob:', result); // Prints 'Hello World!'
}).catch(error => {
throw error;
});
bob.end('End of bob');