Skip to content

Miloas/JSONRpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A simple json-rpc client for nodejs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •