linq.on¶
linq.on(alert_type, alert_callback): Linq
The linq.on() method will set up a callback for the nodejs event emitter. The following alerts and callback signatures are described below.
Parameters¶
Parameter | type | description |
---|---|---|
alert_type | string | Config object or Port number |
alert_callback | function | callback function executed when alert of type is emitted |
Alerts¶
Parameter | callback args |
---|---|
new | Device |
alert | Device, Alert |
timeout | Device |
error | string |
- new
- Emits when a new device is connected to linq
- A Device context is passed to callers event handler
- alert
- Emits when a a device has generated an alert
- A device context and the alert context is passed to the callers event handler
- timeout
- Emites when a device has not been heard from in a period of time specified.
- error
- Emits when linq throws and error
- A string describing the error is passed to the callers event handler
Example Event Handler (New Device)¶
linq.on("new", (device) => {
console.log(`A new device is connected to linq!`);
console.log(`Serial Number: ${device.serial()}`);
});