{"id":19206874,"url":"https://github.com/pkoretic/json_rpc","last_synced_at":"2025-05-12T17:28:14.792Z","repository":{"id":28693635,"uuid":"32213799","full_name":"pkoretic/json_rpc","owner":"pkoretic","description":"Fast and lightweight persistent promise based JSON RPC 2.0 client implementation over TCP and Unix socket","archived":false,"fork":false,"pushed_at":"2015-10-27T20:00:34.000Z","size":202,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-05T20:13:37.752Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pkoretic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-14T13:41:26.000Z","updated_at":"2025-01-17T05:02:53.000Z","dependencies_parsed_at":"2022-09-19T23:22:04.229Z","dependency_job_id":null,"html_url":"https://github.com/pkoretic/json_rpc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Fjson_rpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Fjson_rpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Fjson_rpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Fjson_rpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pkoretic","download_url":"https://codeload.github.com/pkoretic/json_rpc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253786650,"owners_count":21964193,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T13:17:16.313Z","updated_at":"2025-05-12T17:28:14.767Z","avatar_url":"https://github.com/pkoretic.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"json-rpc client\n===============\n\n[![GitHub license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/pkoretic/json-rpc-client/blob/master/LICENSE)  \n[![NPM](https://nodei.co/npm/json-rpc-client.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/json-rpc-client/)\n\nJSON-RPC 2.0 TCP implementation with persistent connections using promises - very fast and without dependencies\n\n## Installation\n\n    npm install json-rpc-client\n\n## Example usage\n### Native promise\n\n    var jsonrpc = require('json-rpc-client')\n\n    // create client and connect\n    var client = new jsonrpc({ port: 7070, host: '127.0.0.1'})\n    client.connect().then(function()\n    {\n        // send json rpc\n        client.send('add', [1,2]).then(function(reply)\n        {\n            // print complete reply\n            console.log(reply)\n        },\n        //transport errors\n        function(error)\n        {\n            console.error(error)\n        })\n    },\n    function(error)\n    {\n        console.error(error)\n    })\n\n### Generators (using co)\n\n    var jsonrpc = require('json-rpc-client')\n    var co = require('co')\n\n    // create client and connect\n    var client = new jsonrpc({ port: 7070, host: '127.0.0.1'})\n\n    co(function*()\n    {\n        try\n        {\n            yield client.connect()\n\n            // send json rpc\n            var reply = yield client.send('add', [1,2])\n\n            // print complete reply\n            console.log(reply)\n        }\n        catch(error)\n        {\n            console.error(error)\n        }\n    })\n\n## API\n\n    var jsonrpc = require('./jsonrpc')\n\n### jsonrpc (options)\n\nCreates a new RPC connection object.\n\nOptions:\n\n* host: Host the client should connect to. Defaults to '127.0.0.1'.\n* port: Port the client should connect to. Defaults to '7070'.\n* keepalive [optional]: if set, keepalive will set using [net-keepalive](https://github.com/hertzg/node-net-keepalive)\n\n### connect\nReturns promise which resolves after the connection to the specified host is ready\n\n### send (methodName, parameters, notification)\n\nSends json data through persisted tcp connection.\n\nmethodName: string\n\nparameters: Object/Array with parameters\n\nnotification: true/false to make notification request (no reply)\n\n* Promise - object containing reply data along with error\n\n### close\n\nCloses RPC connection and returns promise afterwards.\n\n### Event 'error'\n* 'Error Object'\n\nEmitted when an error occurs.\n\n### Event: 'close'\n* 'had_error' 'Boolean' true if the socket had a transmission error\n\nEmitted once the RPC connection socket is fully closed. The argument\n'had_error' is a boolean which says if there was an error.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkoretic%2Fjson_rpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpkoretic%2Fjson_rpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkoretic%2Fjson_rpc/lists"}