machinetalk

1.2.0 • Public • Published

node-machinetalk

This project is in a very early phase. Its goal is to provide an easy to use API for discovering, monitoring and controlling Machinetalk instances.

Build Status Dependency Status

Installation

npm install --save machinetalk

Usage

var machinetalk = require('machinetalk');
 
// Initiate a machine browser that discovers Machinetalk
// machines on the network with their capabilities (services).
var browser = new machinetalk.MachineTalkBrowser();
 
// Wait for services to be discovered.
browser.on('serviceUp', function(service) {
  // We are only interested in the 'status' service.
  if (service.name !== 'status') { return; }
 
  // Initiate a status client that can retrieve status updates.
  var statusclient = new machinetalk.StatusClient(service.dsn);
 
  // Wait for status updates for motion and print them.
  statusclient.on('motionstatuschanged', function(status) {
    console.log('Machine position: ',
      status.position.x,
      status.position.y,
      status.position.z
    );
  });
 
  // Connect to the status service.
  // We are only interested in 'motion' updates.
  statusclient.connect();
  statusclient.subscribe('motion');
});
 
// Start discovering machines.
browser.start();

Examples

See the Examples directory

Readme

Keywords

none

Package Sidebar

Install

npm i machinetalk

Weekly Downloads

1

Version

1.2.0

License

LGPL-3.0

Last publish

Collaborators

  • bobvanderlinden