How to use the network.get_active_interface function in network

To help you get started, we’ve selected a few network examples, based on popular ways it is used in public projects.

github lwmqn / qnode / lib / mqtt-node.js View on Github external
EventEmitter.call(this);

    var self = this,
        transId = 0;

    this.clientId = clientId;
    this.lifetime = Math.floor(devAttrs.lifetime) || 86400;      // seconds
    this.ip = devAttrs.ip || null;
    this.mac = devAttrs.mac || null;
    this.version = devAttrs.version || '0.0.1';

    this.mc = null;     // mqtt client
    this.so = null;     // smart object

    if (!this.ip || !this.mac) {
        network.get_active_interface(function(err, info) {
            if (err) {
                self.emit('error', err);
            } else {
                self.ip = self.ip || info.ip_address;
                self.mac = self.mac || info.mac_address;
            }
        });
    }

    //----------- protected properties ---------------------
    this._rspsToResolve = {};

    this._pubics = {
        register: `register/${this.clientId}`,
        deregister: `deregister/${this.clientId}`,
        notify: `notify/${this.clientId}`,