0

我遇到了 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”没有触发。

4

1 回答 1

0

您可能需要从套接字适配器发出“连接”信号来触发此代码

于 2016-07-14T05:41:42.717 回答