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

Node Meshblu XMPP

Node Meshblu client for XMPP

Build Status Code Climate Test Coverage npm version Gitter

Install

npm install meshblu-xmpp

Example Usage

Set-up

var Meshblu = require('meshblu-xmpp');

var config = {
  hostname: 'meshblu-xmpp.octoblu.com',
  port: 5222,
  uuid: 'cf2497d2-7426-46c4-a229-ad789063bf88',
  token: 'a0178530f1d15f17ddcae60ae7198fc954c2ef53'
}

var conn = new Meshblu(config);

conn.connect(function(error){
  if (error) {
    throw error;
  }
  console.log('Connected');
});

Send Message

var message = {
  "devices": ["*"],
  "payload": "duuude"
};
conn.message(message, function(error){
  if (error) {
    panic(error);
  }
  console.log('Sent Message');
});

On Message

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

Create Session Token

conn.createSessionToken(config.uuid, {"name": "my token"}, function(error, result){
  if (error) {
    panic(error);
  }
  console.log('Create Session Token: ', result);
});

Check status of Meshblu

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

Whoami

conn.whoami(function(error, device){
  if (error) {
    panic(error);
  }
  console.log('Whoami: ', device);
});

Update

  var update = {
    "$set": {
      "type": "device:generic"
    }
  };
  conn.update(config.uuid, update, function(error){
    if (error) {
      panic(error);
    }
    console.log('Updated the device');
  });

Register

// Register a new device

conn.register({"type": "device:generic"}, function(error, device){
  if (error) {
    panic(error);
  }
  console.log('Registered a new 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);
});

Current Tags

  • 1.4.5                                ...           latest (5 years ago)

13 Versions

  • 1.4.5                                ...           5 years ago
  • 1.4.4                                ...           5 years ago
  • 1.4.3                                ...           5 years ago
  • 1.4.2                                ...           5 years ago
  • 1.4.1                                ...           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.2.0                                ...           5 years ago
  • 1.1.1                                ...           5 years ago
  • 1.1.0                                ...           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 1
Dependencies (8)
Dev Dependencies (11)

Copyright 2014 - 2017 © taobao.org |