package
Simple Remote Objects for Node.js
npm install simpleremoteGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Simple Remote Object implementation. It wraps up a Javascript object to use it from other process.
Via npm on Node:
npm install simpleremoteReference it from your program:
var simpleremote = require('simpleremote');Declare and expose an object using a server:
var obj = {
add: function(x,y) {
return x + y;
}
};
var server = simpleremote.createRemoteServer(obj);
server.listen(port);Consuming the remote object from a client:
var client = simpleremote.createRemoteClient();
client.on('remote', function (remote) { // receives an proxy object to remote object
remote.add(1, 2, function (err, value) {
console.log(value); // prints 3
};
});
client.connect(port, host);Declare and expose an object using a client:
var obj = {
add: function(x,y) {
return x + y;
}
};
var client = simpleremote.createRemoteClient(obj);
client.connect(port, host);Consuming the remote object from a server:
var server = simpleremote.createRemoteServer();
server.on('remote', function (remote) { // receives an proxy object to remote object at client connection
remote.add(1, 2, function (err, value) {
console.log(value); // prints 3
};
});
server.listen(port);You can combine both methods.
If the remote method to invoke has a callback as last parameter, you must declare its name at exposing the object:
var obj = {
addAsync: function(x,y, cb) {
// ...
cb(null, x + y);
}
};
var client = simpleremote.createRemoteClient(obj, ['addAsync']);var obj = {
addAsync: function(x,y, cb) {
// ...
cb(null, x + y);
}
};
var server = simpleremote.createRemoteServer(obj, ['addAsync']);TBD: Registry support.
git clone git://github.com/ajlopez/SimpleRemote.git
cd SimpleRemote
npm install
npm testFeel free to file issues and submit pull requests � contributions are welcome.
If you submit a pull request, please be sure to add or update corresponding
test cases, and ensure that npm test continues to pass.
Estimated unpacked size across 3 packages.
28.5 kB
Includes dependencies.