Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The networkhotplug object can be used to generate events when a network interface becomes available or unavailable. A networkhotplugevent will be generated, indicating the interface and whether it was attached or detached.

Note

Reconfiguring a network interface may cause it to detach and attach again.  A DHCP address renewal may cause an event, even if the IP address hasn't changed.

networkhotplug IDL

Code Block
languagejs
interface NetworkHotplugEvent {
    attribute String type;
    attribute bool attached; // 1 -> attached, 0 -> detached
    attribute String interfaceName;
};

callback NetworkHotplugEventCallback = void (NetworkHotplugEvent event);

interface NetworkHotplug {
    void addEventListener(String type, NetworkHotplugEventCallback callback);
    void removeEventListener(String type, NetworkHotplugEventCallback callback);
}; 
Panel
borderColor#3D3D3D
bgColor#F4F4F4
titleColor#3D3D3D
borderWidth0
titleBGColor#3D3D3D
borderStylesolid

ON THIS PAGE

Table of Contents
indent20px



Event Creation

To create a networkhotplug event, load the @brightsign/networkhotplug module using the Node.js® require() method:

Code Block
languagejs
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
languagejs
let networkhotplugClass = require("@brightsign/networkhotplug");
let networkhotplug = new networkhotplugClass();

networkhotplug.addEventListener("networkhotplugevent", onNetworkHotplugEvent);    

function onNetworkHotplugEvent(data) {
  if (data.attached)
{     // connected on 'data.interfaceName'   }
}