Handlers
When communicating with the stream, a number of notifications are emitted.
Connect
Emitted on successful connection.
x
// Create an instance of Wia// Replace 'd_sk_abcdef' with your device secret keyvar wia = require('wia')('d_sk_abcdef');// Listen for a successful connection to the MQTT APIwia.stream.on('connect', function() { console.log("Connected to the stream!");});Reconnect
Emitted when a reconnect starts.
// Create an instance of Wia// Replace 'd_sk_abcdef' with your device secret keyvar wia = require('wia')('d_sk_abcdef');// Listen for a reconnectionwia.stream.on('reconnect', function() { console.log("Reconnect emitted.");});Disconnect
Emitted after a disconnection.
// Create an instance of Wia// Replace 'd_sk_abcdef' with your device secret keyvar wia = require('wia')('d_sk_abcdef');// Listen for a disconnectionwia.stream.on('disconnect', function() { console.log("Disconnect emitted.");});Offline
Emitted when the client goes offline.
// Create an instance of Wia// Replace 'd_sk_abcdef' with your device secret keyvar wia = require('wia')('d_sk_abcdef');// Listen for an offlinewia.stream.on('offline', function() { console.log("Offline emitted.");});Error
Emitted when a client cannot connect or a parsing error occurs.
// Create an instance of Wia// Replace 'd_sk_abcdef' with your device secret keyvar wia = require('wia')('d_sk_abcdef');// Listen for a errorwia.stream.on('error', function(err) { console.log("Error emitted."); console.log(err);});