node-pa-rpc
v1.0.3
Published
``` const { NodeRpcClient, NodeRpcServer } = require('node-pa-rpc'); const rpcServer = new NodeRpcServer('12200'); const server = rpcServer.createServer((error, paramsData, socket) => { if (error) { console.log(error); return; }
Downloads
6
Readme
npm install node-pa-rpc --save
const { NodeRpcClient, NodeRpcServer } = require('node-pa-rpc');
const rpcServer = new NodeRpcServer('12200');
const server = rpcServer.createServer((error, paramsData, socket) => {
if (error) {
console.log(error);
return;
}
socket.write(rpcServer.serializeResponse({ ok: true }));
});
server.on('close', () => {
console.log('server is close');
})
server.on('error', error => {
console.log(error);
})
const rpcClient = new NodeRpcClient('127.0.0.1', '12200', 3000);
rpcClient.request(1, { hh: 'ddddd' }).then(result => {
console.log(result)
});