Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 54 Next »

The networkhotplug object can be used to generate events when a network interface becomes available or unavailable. The networkhotplug event is raised when a physical cable is plugged into a device. A network being connected further upstream does not cause a reaction.


networkhotplug IDL
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);
}; 


Event Creation

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


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 

  • [string] type: Add or remove an event listener when this type of event occurs.
  • [bool] attached: Can be true or false (1 is attached, 0 is detached)
  • [string] interfaceName: Returns the interface name (for example, "eth0")


Example

let networkhotplugClass = require("@brightsign/networkhotplug");
let networkhotplug = new networkhotplugClass();

networkhotplug.addEventListener("networkhotplugevent", onNetworkHotplugEvent);    

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



  • No labels