xmlrpc-stream v0.0.1
xmlrpc-stream
Perform XML-RPC using any kind of stream!
Overview
xmlrpc-stream implements the XML and RPC bits of XML-RPC without the implied transport portion. Any duplex stream can be used as a transport.
Installation
Available via npm:
$ npm install xmlrpc-stream
Or via git:
$ git clone git://github.com/deoxxa/xmlrpc-stream.git node_modules/xmlrpc-stream
API
constructor
Creates a new RPC object. Expects a stream factory function as an argument. This factory function will be called whenever a transport is required (read: every single time you call a remote method).
new RPC(fn);
var rpc = new RPC(function() {
return net.connect(3000, "127.0.0.1");
});
call
Calls a remote method by name, optionally with some parameters, then calls your callback with the result (or an error! woo!).
rpc.call(method, [arg1, [arg2, [argN ...]]], cb);
rpc.call("system.listMethods", function(err, res) {
console.log(err, res);
});
// OR
rpc.call("system.methodSignature", "system.listMethods", function(err, res) {
console.log(err, res);
});
Arguments
- method - a string, naming the remote method to call.
- argN - the parameters for the remote method.
- cb - a callback to be called when the response comes in.
Example
Also see example.js.
This uses scgi-stream as well, but you
could just as easily replace that with net.connect
or something if you had a
remote server that supported XML-RPC over regular TCP sockets.
var scgi = require("scgi-stream"),
RPC = require("xmlrpc-stream");
var rpc = new RPC(function() {
return scgi.duplex({
host: "127.0.0.1",
port: 17199,
path: "/",
});
});
rpc.call("d.multicall", "default", "d.get_creation_date=", "d.get_bytes_done=", "d.get_directory=", "d.get_down_rate=", "d.get_up_rate=", "d.get_down_total=", "d.get_up_total=", function(err, res) {
console.log(err, res);
});
License
3-clause BSD. A copy is included with the source.
Contact
- GitHub (deoxxa)
- Twitter (@deoxxa)
- ADN (@deoxxa)
- Email (deoxxa@fknsrs.biz)
11 years ago