小编MDa*_*ave的帖子

如何防止超过 2 个 tokbox 客户端?

我有以下代码:

openTokInit() {
    this.session = OT.initSession(this.tokboxApiKey, this.sessionId);
    const self = this;
    this.session.on('connectionCreated', function(event) {
        self.connectionCount++;
    });

    if (this.connectionCount < 2) {
        this.session.connect(this.token, err => {
            if (err) {
                reject(err);
            } else {
                resolve(this.session);
            }
        });
    }
Run Code Online (Sandbox Code Playgroud)

问题是当 if 语句运行时,connectionCount 始终为 0,因为 'connectionCreated' 事件在几秒钟后被触发。我不清楚如何在连接新会话之前适当地等待所有 connectionCreated 事件触发。

javascript opentok angular

2
推荐指数
1
解决办法
790
查看次数

标签 统计

angular ×1

javascript ×1

opentok ×1