0.3.20 • Published 7 years ago

JSONRpc v0.3.20

Weekly downloads
13
License
MIT
Repository
github
Last release
7 years ago

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()
0.3.20

7 years ago

0.3.10

7 years ago

0.3.9

7 years ago

0.3.8

7 years ago

0.3.7

7 years ago

0.3.6

7 years ago

0.2.6

7 years ago

0.2.5

7 years ago

0.2.4

7 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago