我必须克隆节点modesl模块才能使其在类或函数中工作

时间:2019-04-23 14:33:08

标签: node.js freeswitch

我正在编写一个nodejs类以与modesl一起使用(freswitch事件模块)

'use strict';

const esl        = require('modesl');

class eslClass {
    connect() {
        this.fswcon = new esl.Connection(config.fswEslHost, config.fswEslPort, 'ClueCon', () => {
            this._listen();
        });
    }
}
// connect() will failed with a 'this.once' is undefined ( .once is coming from eventEmitter2, i believe )

我必须“克隆”对象以取消错误

const eslClone = esl.Connection;
class eslClass {
    connect() {
        this.fswcon = new eslClone (config.fswEslHost, config.fswEslPort, 'ClueCon', () => {
            this._listen();
        });
    }
}
// error is gone away !!

0 个答案:

没有答案