iothub-browser
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

IotHub Browser Only Package

Features:

  • Receives Cloud-to-device messages
  • Sends Device-to-cloud messages
  • Monitors all IotHub Messages

Install

Run npm install --save-dev iothub-browser

How to Use IotHub Device(in the browser)

Assuming you are using a bundler like browserify or webpack

import {connectDevice} from 'iothub-browser'
 
const {publish, close} = connectDevice('{device connection string from iothub}', (topic, c2dMessage) => {
  console.log(c2dMessage)
})
 
publish(JSON.stringify({message: "hello world"}), {prop1: "looks good"})
 
// ... to close the connection
close()

How to Use Event Monitoring

Event Monitoring uses the events Iothub endpoint which is a eventhub-compatible endpoint.

import {monitorEvents} from 'iothub-browser'
 
const {close} = monitorEvents('{eventhub-name}', '{eventhub-compatible-connection-string}', (message, context) => {
  console.log(message)
  console.log(context)
})
 
// ... to close the monitor connection
 
close()

/iothub-browser/

    Package Sidebar

    Install

    npm i iothub-browser

    Weekly Downloads

    2

    Version

    1.3.0

    License

    MIT

    Unpacked Size

    107 kB

    Total Files

    27

    Last publish

    Collaborators

    • howlowck