fib-rpc
Remote Procedure Calling for fibjs
Introduction
fib-rpc
is working on dispatching of remote procedure calling, it supports both http request and websocket(recommended).
obviously, it follows JSON-RPC protocol.
Get Started
npm i -S fib-rpc
Usage
you can use it with http.Request
var js_remote = rpc; { var m = ; mvalue = 'test/tttt/tttt/'; m; ; mresponsebody; return mresponse;} var result = assert;
but in most cases, you may prefer using it based on Websocket
, which finshied by rpc.connect
const ws = const http = const rpc = const svr = 8811 ws;svr; const remoting = rpc; remoting // 3
Learn connect
from test case 'websocket rpc'
in exmaple.
Custom Errors
use RpcError
as typed Error thrown if required:
const rpc = const js_remote = rpc; const svr = 8811 ws; const remoting = rpc; try remoting catch err_msg console // 'Addend must be integer' console // code: 4010000, message: 'Addend must be integer'
Samples
View Samples, test them like this:
# build lib first. npm i && npm run build # chdir to examples cd exapmlesnpm i # run example fibjs ./connect.jsfibjs ./open_handler-js.js