meshblu-firehose-socket.io
Meshblu Firehose Client for socket.io
Last updated 3 years ago by octoblu .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install meshblu-firehose-socket.io 
SYNC missed versions from official npm registry.

node-meshblu-firehose-socket.io

Meshblu Firehose client for socket.io, stream messages from Meshblu Subscriptions.

Build Status Code Climate Test Coverage Slack Status

NPM

Table of Contents

Getting Started

Install

The Meshblu Firehose socket.io client-side library is best obtained through NPM:

npm install --save meshblu-firehose-socket.io

Quick Start

The client side library establishes a secure socket.io connection to Meshblu Firehose at https://meshblu-firehose-socket-io.octoblu.com by default.

var MeshbluFirehoseSocketIO = require('meshblu-firehose-socket.io');
var firehose = new MeshbluFirehoseSocketIO({
  meshbluConfig: {
   hostname: 'meshblu-firehose-socket-io.octoblu.com',
   port: 443,
   protocol: 'wss',
   uuid: '78159106-41ca-4022-95e8-2511695ce64c',
   token: 'd5265dbc4576a88f8654a8fc2c4d46a6d7b85574'
  }
})
firehose.connect();

Events

Event: "message"

The message event is emitted whenever a device sends or receives a message. In order to receive broadcast from a device, your connection must be authenticated as a device that is in the target device's broadcast.sent whitelist. To receive message sent by a device, your connection must be in the target's message.sent whitelist. To receive messages from other devices, they must be in the authorized device's message.from whitelist. See the Meshblu whitelist documentation for more information.

  • message Message object that was received.
    • metadata Object containing metadata about the message, including the route.
    • data The contents of the message.
Example
firehose.on('message', function(message){
  console.log('on message');
  console.log(JSON.stringify(message, null, 2));
  // on message
  // {
  //   "metadata": {
  //     "responseId": "21af8d3c-002b-4967-b725-71b2369a6ccf",
  //     "route": [
  //       {
  //         "from": "10ab5232-21ff-418b-8153-7b1d80cdc426",
  //         "to": "b0af12c9-4aea-4a48-9cea-53efd759653c",
  //         "type": "broadcast.sent"
  //       },
  //       {
  //         "from": "10ab5232-21ff-418b-8153-7b1d80cdc426",
  //         "to": "b0af12c9-4aea-4a48-9cea-53efd759653c",
  //         "type": "broadcast.received"
  //       },
  //       {
  //         "from": "b0af12c9-4aea-4a48-9cea-53efd759653c",
  //         "to": "b0af12c9-4aea-4a48-9cea-53efd759653c",
  //         "type": "broadcast.received"
  //       }
  //     ]
  //   },
  //   "data": {
  //     "devices": [
  //       "*"
  //     ],
  //     "data": "2016-07-09T04:57:22.998Z"
  //   }
  // }
});

otherConn.message({devices: ['*'], data: new Date()});

Methods

constructor(options)

Establishes a socket.io connection to Meshblu Firehose and returns the connection object.

Arguments
  • options connection options with the following keys:
    • protocol The protocol to use when connecting to the server. Must be one of ws/wss (Default wss)
    • hostname The hostname of the Meshblu server to connect to. (Default: meshblu-firehose-socket-io.octoblu.com)
    • port The port of the Meshblu server to connect to. (Default: 443)
    • uuid UUID of the device to connect with.
    • token Token of the device to connect with.
Example
var MeshbluFirehoseSocketIO = require('meshblu-firehose-socket.io');
var conn = new MeshbluFirehoseSocketIO({
  hostname: 'meshblu-firehose-socket-io.octoblu.com',
  port: 443,
  protocol: 'wss',
  uuid: '78159106-41ca-4022-95e8-2511695ce64c',
  token: 'd5265dbc4576a88f8654a8fc2c4d46a6d7b85574'
})

#firehoseconnect

meshblu.connect()

Establish a socket.io connection to Meshblu Firehosea.

Note

Connect no longer takes a callback. message events will be emitted as soon as messages are received from Meshblu. On disconnect events the firehose will attempt to automatically reconnect.

Example
firehose.on('connecting', function() {
  console.log('connecting...');
})
firehose.on('connect', function() {
  console.log('connected!');
})
firehose.on('connect_error', function(error) {
  console.error('connect_error', error)
})
firehose.on('disconnect', function() {
  console.log('disconnected!');
})
firehose.on('reconnecting', function() {
  console.log('reconnecting...');
})

firehose.connect()

Current Tags

  • 4.0.2                                ...           latest (3 years ago)

32 Versions

  • 4.0.2                                ...           3 years ago
  • 4.0.0                                ...           4 years ago
  • 3.0.1                                ...           4 years ago
  • 3.0.0                                ...           4 years ago
  • 2.2.0                                ...           4 years ago
  • 2.1.0                                ...           4 years ago
  • 2.0.13                                ...           4 years ago
  • 2.0.12                                ...           4 years ago
  • 2.0.11                                ...           4 years ago
  • 2.0.10                                ...           4 years ago
  • 2.0.9                                ...           4 years ago
  • 2.0.8                                ...           4 years ago
  • 2.0.7                                ...           4 years ago
  • 2.0.4                                ...           4 years ago
  • 2.0.3                                ...           4 years ago
  • 1.7.1                                ...           4 years ago
  • 2.0.2                                ...           4 years ago
  • 2.0.1                                ...           4 years ago
  • 2.0.0                                ...           4 years ago
  • 1.7.0                                ...           5 years ago
  • 1.6.0                                ...           5 years ago
  • 1.5.0                                ...           5 years ago
  • 1.4.3                                ...           5 years ago
  • 1.4.2                                ...           5 years ago
  • 1.4.1                                ...           5 years ago
  • 1.4.0                                ...           5 years ago
  • 1.3.2                                ...           5 years ago
  • 1.3.0                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (6)
Dev Dependencies (10)

Copyright 2014 - 2017 © taobao.org |