meshblu-amqp
AMQP client for Meshblu
Last updated 5 years ago by octoblu .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install meshblu-amqp 
SYNC missed versions from official npm registry.

node-meshblu-amqp

AMQP client library for Meshblu

Build Status Code Climate Test Coverage npm version Gitter

Install

npm install meshblu-xmpp

Example Usage

Set-up

var meshblu = require('meshblu-amqp');

var config = {
  'hostname': 'meshblu-amqp.octoblu.com',
  'port': 5672,
  'uuid': '',
  'token': ''
}

var conn = new meshblu(config);

conn.connect(function(data){

}); // conn.connect

Send Message

conn.message({"devices": ["*"], "payload": "duuude"}, function(result){
  console.log('Send Message: ', result);
});

On Message

// Message handler
conn.on('message', function(message){
  console.log('Message Received: ', message);
});

Create Session Token

conn.createSessionToken(config.uuid, {"createdAt": Date.now()},
function(err, result){
  console.log('Create Session Token: ', result);
});

Check status of Meshblu

conn.status(function(err, result){
  console.log('Status:', result);
});

Whoami

conn.whoami(function(err, result){
  console.log('Whoami: ', result);
});

Update

// Update a specific device - you can add arbitrary json
conn.update(config.uuid, { "$set": {"type": "device:generic"}}, function(err, device){
  console.log('Update Device:', device);
});

Register

// Register a new device
conn.register({"type": "device:generic"}, function(err, device){
  console.log('Register Device: ', device);
});

Subscribe

// Subscribe to your own messages to enable recieving them
// conn.unsubscribe takes the same arguments
var subscription = {
  "subscriberUuid" : config.uuid,
  "emitterUuid": config.uuid,
  "type": 'message.received'
};
conn.subscribe(config.uuid, subscription, function(err, result){
  console.log('Subscribe: ', result);
});

Search Devices

// Search for devices by a query
var query = {
  "type": "device:generic"
};
conn.searchDevices(config.uuid, query, function(err, result){
  console.log('Search Devices: ', result);
  console.log(err);
});

Testing

You'll need to add some users to your test rabbitmq instance

rabbitmqctl add_user meshblu judgementday
rabbitmqctl set_permissions meshblu ".*" ".*" ".*"
rabbitmqctl add_user some-uuid some-token
rabbitmqctl set_permissions some-uuid '^(amq\.gen.*|amq\.default|^some-uuid.*)$' '.*' '.*'

Current Tags

  • 1.5.0                                ...           latest (5 years ago)

10 Versions

  • 1.5.0                                ...           5 years ago
  • 1.4.3                                ...           5 years ago
  • 1.4.0                                ...           5 years ago
  • 1.3.2                                ...           5 years ago
  • 1.3.1                                ...           5 years ago
  • 1.3.0                                ...           5 years ago
  • 1.2.1                                ...           5 years ago
  • 1.1.1                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (6)
Dev Dependencies (13)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |