npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@datagica/remoting.io-tweaked

v0.1.3

Published

Simple and transparent remote procedure calls (RPC) using Engine.IO. Tweaked to make things happen.

Downloads

5

Readme

Remoting.IO

Simple and transparent remote procedure calls (RPC) using Engine.IO.

The client repository is located here.

About

Remoting.IO allows services to export methods remotely. Services are simply plain prototypical Javascript classes which define a number of methods that can be called remotely.

Because Engine.IO is connection oriented, services are stateful. This means session data can be persisted across services and method invocations. Remoting.IO provides a session hash map that is injected into instances of services for exactly this purpose.

Remoting.IO is able to handle both synchronous and asynchronous methods. The only constraint is that asynchronous methods must return an ES6 promise.

Because Remoting.IO is based on Engine.IO, it inherits the strengths of Engine.IO, such as multiple transports and resilience in the presence of proxies, load balancers, and firewalls.

Installation

Install Engine.IO and Remoting.IO with:

npm install engine.io
npm install remoting.io

Server Example

Define a service as follows:

function TestService(arg1, arg2) {
	this.arg1 = arg1;
	this.session['arg2'] = arg2;
}

TestService.prototype.test1 = function (str1, str2) {
	return str1 + str2;
};

TestService.prototype.test2 = function () {
	var self = this;

	return new Promise(function (resolve) {
		resolve(self.arg1 + self.session['arg2']);
	});
};

TestService.exports = [ 'test1', 'test2' ];

Setup the RPC server as follows:

var engine = require('engine.io');
var remoting = require('remoting.io');

var socketServer = engine.listen(80);
var rpcServer = remoting(socketServer);

rpcServer.addService('TestService', TestService, ['Hello', 'World!']);
rpcServer.start();

When a client connects and requests an instance of TestService, 'Hello' and 'World!' will be passed into arg1 and arg2 of the service constructor respectively.

Client Example

Using the server example above, we can remotely request an instance of the service and call it's method as follows:

var socket = eio('ws://localhost');
var client = rio(socket);
	
client.proxy('TestService').then(function (testService) {
	testService.test1('Hello', 'World!').then(function (result) {
		console.log(result);
		testService.release();
	});	
});

This example assumes that engine.io.js and remoting.io.js have been loaded into the DOM.

Using Browserify:

var socket = require('engine.io-client')('ws://localhost');
var client = require('remoting.io-client')(socket);
	
client.proxy('TestService').then(function (testService) {
	testService.test1('Hello', 'World!').then(function (result) {
		console.log(result);
		testService.release();
	});	
});

API

Server

  • constructor

    • Initializes the server
    • Parameters:
      • socketServer: an Engine.IO (or equivalent) server instance
  • start

    • Starts the RPC server
  • stop

    • Stops the RPC server
  • addService

    • Registers an RPC service
    • Parameters:
      • name: The service identifier
      • service: The service class
      • args: Arguments that are passed to the service constructor when a new instance of the service is created
  • removeService

    • Unregisters an RPC service
    • Parameters:
      • name: The service identifier

Head over to the Remoting.IO client repository for instructions on how to use the client.

License

Copyright (c) 2015 James McLean
Licensed under the MIT license.