1.2.0 • Published 9 years ago

nexus-uplink-client v1.2.0

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

Nexus Uplink Client (Isomorphic)

Nexus Uplink is an dead-simple, lightweight protocol on top of which Flux over the Wire can be implemented.

On the client side, a Nexus Uplink Client can react to stores updates, and dispatch actions. On the server side, a Nexus Uplink Server can react to actions dispatchs, and update stores.

Briefly:

  • actions are transported via POST requests (url pathname is the action identifier, JSON-encoded body is the payload)
  • updates are transported via Websocket (or Engine.IO fallback) (as diff objects)

This package is an isomorphic (which means it can run on either Node.js or in the browser via browserify/webpack) implementation of the Nexus Uplink client-side protocol. Also see the simple server implementation of the Nexus Uplink server-side protocol.

Example

On the server:

var server = new UplinkSimpleServer({
  pid: _.guid('pid'),
  // stores, rooms and actions are url patterns whitelists
  stores: ['/ping'],
  rooms: [],
  actions: ['/ping'],
  // pass an express or express-like app
  app: express().use(cors())
});

var pingCounter = 0;

// setup action handlers
server.actions.on('/ping', function(payload) {
  // guid is a cryptosecure unique user id, automatically maintained
  var guid = payload.guid;
  var remoteDate = payload.localDate;
  var localDate = Date.now();
  console.log('client ' + guid + ' pinged.');
  console.log('latency is ' + (localDate - remoteDate) + '.');
  pingCounter++;
  server.update({ path: '/ping', value: { counter: pingCounter }});
});

On the client:

var client = new Uplink({ url: 'http://localhost' });

// subscribe to remote updates
client.subscribeTo('/ping', function(ping) {
  console.log('ping updated', ping.counter);
});

// fire-and-forget dispatch actions
setInterval(function() {
  client.dispatch('/ping', { localDate: Date.now() });
}, 1000);

Installation

npm install nexus-uplink-simple-server --save

1.2.0

9 years ago

1.1.3

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.11.15

9 years ago

0.11.14

9 years ago

0.11.13

9 years ago

0.11.12

9 years ago

0.11.11

9 years ago

0.11.10

9 years ago

0.11.9

9 years ago

0.11.8

9 years ago

0.11.7

9 years ago

0.11.6

9 years ago

0.11.5

9 years ago

0.11.4

9 years ago

0.11.3

9 years ago

0.11.2

9 years ago

0.11.1

9 years ago

0.11.0

9 years ago

0.10.1

9 years ago

0.10.0

9 years ago

0.9.2

9 years ago

0.9.1

9 years ago

0.9.0

9 years ago

0.8.17

9 years ago

0.8.16

9 years ago

0.8.15

9 years ago

0.8.14

9 years ago

0.8.13

9 years ago

0.8.12

9 years ago

0.8.11

9 years ago

0.8.10

9 years ago

0.8.9

9 years ago

0.8.8

9 years ago

0.8.7

9 years ago

0.8.6

9 years ago

0.8.5

9 years ago

0.8.4

9 years ago

0.8.3

9 years ago

0.8.2

9 years ago

0.8.1

9 years ago

0.8.0

9 years ago

0.7.0

9 years ago

0.6.0

9 years ago

0.5.5

9 years ago

0.5.4

9 years ago

0.5.3

9 years ago

0.5.2

9 years ago

0.5.1

9 years ago

0.5.0

9 years ago

0.4.0

9 years ago

0.3.2

9 years ago

0.3.1

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago