Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chains-amqp

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chains-amqp

This package is an abstract class for Chains NodeJS-devices.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

Chains AMQP

SUMMARY

This package is an abstract class for Chains NodeJS-devices. It requires node-amqp. The class connects to RabbitMQ and emits events based on actions being trigged in Chains. It also handles heart beats.

INSTALLING

npm install chains-amqp

Or put this in your package.json

"dependencies": {
    "chains-amqp": "*"
}

USAGE

If you are going to create a new Chains-device. You can do it like this:

Example one

var amqp = require('chains-amqp').connect({deviceName: 'xcomfort'});

amqp.on('on', function(deviceId, actionId) {
    var light = lights.findWhere({serial: deviceId});
    
    if (light) {
        light.set('isOn', true);
    
        amqp.sendResponse('on', actionId);
    }
});

Example two

var amqp = require('chains-amqp').connect({deviceName: 'xcomfort'});

amqp.on('describe', function(deviceId, actionId) {
    var events = [
        [ 'xcomfort-on', {
            'key': ['str', null, 'Event trigger'],
            'value': ['int', null, 'Light ID']
            }, 'Action to turn on a single device. Needs value to be a ID of a device']
        ];
    
    var actions = [
        [ 'action_on', {
            'key': ['str', null, 'device Id'],
            'value': ['int', null, 'Light ID']
            }, 'Action to turn on a single device. Needs value to be a ID of a device'],

        [ 'action_off', {
            'key': ['str', null, 'device Id'],
            'value': ['int', null, 'Light ID']
            }, 'Action to turn on a single device. Needs value to be a ID of a device']
    ];
    
    amqp.sendResponse('describe', actionId, {
        'info': 'Controll XComfort-devices. Lights etc',
        'actions': actions,
        'events': events
    });
});

LICENSE

MIT, see the LICENSE file

Keywords

FAQs

Package last updated on 28 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc