npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

meshblu-firehose-socket.io

v4.0.2

Published

Meshblu Firehose Client for socket.io

Downloads

104

Readme

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()