【问题标题】:Using Pusher with SimpleWebRTC将 Pusher 与 SimpleWebRTC 一起使用
【发布时间】:2016-07-14 03:29:15
【问题描述】:

我遇到了 SimpleWebRTC 包。试图让它工作,但似乎无法让远程流通过。我也在使用 Pusher 来发送信号,而不是 SimpleWebRTC 附带的默认值。

我已经建立了自己的连接:

var myConnection = {
  pusher: new Pusher('mypusherkey', { cluster: 'ap1' } ),
  channel: null, 

    on: function (event, callback) { 
        this.pusher.bind (event, callback); 
    },
    emit: function () { 
        if (arguments.length == 1) {
            if (arguments[0] === "join") {
                this.channel = this.pusher.subscribe(arguments[1]);
            } 
        }
        else 
            this.channel.trigger(arguments); 
    },
    getSessionId: function() { 
        return this.pusher.connection.socket_id;  
    },
    disconnect: function() { 
        this.pusher.disconnect(); 
    }
};

然后我进行 SimpleWebRTC 初始化:

var webrtc = new SimpleWebRTC({
  // the id/element dom element that will hold "our" video
  localVideoEl: 'localVideo',
  // the id/element dom element that will hold remote videos
  remoteVideosEl: 'remotesVideos',
  // immediately ask for camera access
  autoRequestMedia: true,
  debug: true,
  connection: myConnection
});

// we have to wait until it's ready
webrtc.on('readyToCall', function () {
    console.log('ready to join');
  // you can name it anything
  webrtc.joinRoom('test-video-chat');
});

在两台电脑之间做一个简单的测试,它没有设置远程流。在开发控制台中,除了初始事件连接之外,我没有看到任何其他活动发生,尤其是 SimpleWebRTC“readyToCall”没有触发。

【问题讨论】:

    标签: javascript pusher simplewebrtc


    【解决方案1】:

    您可能需要从您的套接字适配器发出一个“连接”信号来触发this code

    【讨论】:

    • 您能详细说明一下吗?我应该在哪里触发连接?
    • 我的 Pusher 连接也正确吗?还是我错过了什么?
    • 在 github 存储库的一篇文章中,有人提供了帮助,他们指出我需要听一些事件。我已经尝试过,但我仍然无法让它工作。我现在只是对我应该听什么事件以及应该如何处理它们感到困惑。
    猜你喜欢
    • 1970-01-01
    • 2012-04-13
    • 2020-12-27
    • 2021-12-21
    • 2019-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-09
    相关资源
    最近更新 更多