How to use the coap.globalAgent function in coap

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

github PeterEB / coap-shepherd / lib / coap-shepherd.js View on Github external
function CoapShepherd(config) {
    EventEmitter.call(this);

    this.clientIdCount = 1;

    this._setConfig(config);

    this._net = {
        intf: '',
        ip: this._config.ip,
        port: this._config.port,
        mac: '',
        routerIp: ''
    };

    this._agent = coap.globalAgent;
    this._registry = {};
    this._server = null;

    this._enabled = false;
    this._joinable = false;
    this._hbChecker = null;
    this._permitJoinTime = 0; 
    this._permitJoinTimer = null;

    coap.updateTiming({
        maxLatency: (this._config.reqTimeout - 47) / 2
    });

    this._acceptDevIncoming = function (devInfo, callback) {   // Override at will.
        setImmediate(function () {
            var accepted = true;
github PeterEB / coap-shepherd / lib / init.js View on Github external
});

    if (shepherd._config.connectionType === 'udp6') {
        coap.globalAgentIPv6 = new coap.Agent({
            type: shepherd._config.connectionType,
            socket: server._sock
        });

        shepherd._agent = coap.globalAgentIPv6;
    } else {
        coap.globalAgent = new coap.Agent({
            type: shepherd._config.connectionType,
            socket: server._sock
        });
        
        shepherd._agent = coap.globalAgent;
    }
    
    
    return deferred.promise.nodeify(callback);
};