You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

JSONRpc

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

JSONRpc

an json-rpc 2.0 client lib for nodejs

0.3.20
latest
Source
npmnpm
Version published
Weekly downloads
13
-61.76%
Maintainers
1
Weekly downloads
 
Created
Source

JSONRpc

json-rpc 2.0 client

Test

// to Start an json-rpc 2.0 server 
go run test/testServer.go
// do test
npm test

Install

npm i JSONRpc --save

Use

var JSONRpcClient = require('JSONRpc')

const client = new JSONRpcClient('localhost', 8080)

client.call('add', [1,7], (err, ret) => {
    // 8
    if(!err) console.log(ret)
})

// Promise also support
(async () => {
    let ret = await client.callPromise('add', [1,2])
    // 3
    console.log(ret)
})()

//Json-rpc over websocket
//It will periodically call add function, and reseive every result from callback
client.callOverWs('add', [1, 2], function (err, ret) {
    console.log(ret)
}, 1000)

//It will call add once 
client.callOverWs('add', [1, 2], function(err, ret) {
    console.log(ret)
})

//Close the connection
client.closeWs()

Keywords

json-rpc

FAQs

Package last updated on 06 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts