Skip to content

Provides RPC functionality over WebSockets using the JSON-RPC protocol.

Notifications You must be signed in to change notification settings

vanillajonathan/jsonrpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

jsonrpc.js

Provides RPC functionality over WebSockets using the JSON-RPC protocol.

Example

const socket = new WebSocket('wss://www.example.com/rpc');
const rpc = new JSONRPC(socket);
// ...
rpc.call('greet', { name: 'Alice' }).then(function(response) {
    console.log("Success!", response);
}).catch(function(error) {
    console.log("Failed!", error);
});

Send a RPC notification (does not get a response).

rpc.notify('greet', { name: 'Alice' });

Error listeners

rpc.onerror = (error) => console.error(error);
rpc.onResponseError = (error) => console.warn(error);

About

Provides RPC functionality over WebSockets using the JSON-RPC protocol.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published