forked from fiddlerwoaroof/node-jsonrpc2
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed README to use Markdown and added install instructions.
- Loading branch information
Showing
2 changed files
with
43 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# node-jsonrpc2 | ||
|
||
This is a JSON-RPC server and client library for node.js <http://nodejs.org/>, | ||
the V8 based evented IO framework. | ||
|
||
## Install | ||
|
||
To install node-jsonrpc2 in the current directory, run: | ||
|
||
npm install jsonrpc2 | ||
|
||
## Usage | ||
|
||
Firing up an efficient JSON-RPC server becomes extremely simple: | ||
|
||
``` javascript | ||
var rpc = require('jsonrpc'); | ||
|
||
function add(first, second) { | ||
return first + second; | ||
} | ||
rpc.expose('add', add); | ||
|
||
rpc.listen(8000, 'localhost'); | ||
``` | ||
|
||
And creating a client to speak to that server is easy too: | ||
|
||
``` javascript | ||
var rpc = require('jsonrpc'); | ||
var sys = require('sys'); | ||
|
||
var client = rpc.getClient(8000, 'localhost'); | ||
|
||
client.call('add', [1, 2], function(result) { | ||
sys.puts('1 + 2 = ' + result); | ||
}); | ||
``` | ||
|
||
To learn more, see the examples directory, peruse test/jsonrpc-test.js, or | ||
simply "Use The Source, Luke". | ||
|
||
More documentation and development is on its way. |