code-proxy
A Node.js tools that give the ability to execute JavaScript code in one client browser and to get the results in another. Based on HTTP (for static files and sync post requests) and WebSocket (for server-host communications) technologies. Supports CommonJS modules and can be used with Webpack or Browserify on the client-side.
Scheme to illustrate base working principles:
Installation
npm install code-proxy
Use
Start as a standalone server:
node server/main.js
Connect to an existing project:
; // or it's possible to redefine default options portHttp: 8800 portWs: 8900 retryDelay: 100 retryLimit: 30 logging: true;
Examples
Host client (accepts requests, execute them and send back result of execution):
// default host/port/sessionvar proxy = ; // prepare for guest calllocalStorage; // test func for remote exec { return 'some host work with "' + param + '" is done';}
Guest client (send requests to the host):
// default host/port/sessionvar proxy = ; // examplesproxy;proxy;proxy;proxy;proxy;
Proxy server host/port and session name can be redefined on both host and guest:
var proxy = host: '127.0.0.1' port: 8800 name: 'anonymous';
Both host and guest proxy instance have active
boolean flag to determine the current connection to the proxy server status.
ProxyHost has some additional options: reconnect
and reconnectInterval
to automatically try to restore connection on disconnect every 5 seconds. It's active be default.