Event Creation
To create a networkhotplug event, load the @brightsign/networkhotplug module using the Node.js® require() method:
Code Block | ||
---|---|---|
| ||
let networkhotplugClass = require("@brightsign/networkhotplug"); let networkhotplug = new networkhotplugClass(); |
NetworkHotPlug
Use this interface to configure a networkhotplug event.
networkhotplugevent
: This event is raised when the hotplug status changes. Use the addEventListener()
method to listen for this event, or the removeEventListener()
method to remove an event listener.
NetworkHotPlugEvent Properties
[type
string] type: Add or remove an event listener when this type of event occurs.[attached
bool] attached: Can be true or false (1 is attached, 0 is detached)[interfaceName
string] interfaceName: Returns the interface name (for example, "eth0")
Example
Code Block | ||
---|---|---|
| ||
let networkhotplugClass = require("@brightsign/networkhotplug"); let networkhotplug = new networkhotplugClass(); networkhotplug.addEventListener("networkhotplugevent", onNetworkHotplugEvent); function onNetworkHotplugEvent(data) { if (data.attached) { // connected on 'data.interfaceName' } } |