These are chat archives for andyet/SimpleWebRTC

21st
Jun 2016
Bastian Heist
@beheist
Jun 21 2016 12:47
Hey folks, I can't seem to manage repeated room joins/leaves by users. What do I need to do so that SimpleWebRTC is reset to it's "default" state?
Second time I try to start a call, either there is no stream (peers don't get connected), which happens if I delete the webrtc object and create a new one.
Im currently doing:
var webrtc = null;

    /**
     * This listens to webrtc events and triggers the according functions.
     */
    onlineStatus.on("webrtc", function (event) {
        switch (event) {
            case 'joinroom':
                var roomName = 'test';
                // Initialize simpleWebRTC
                if (!webrtc) {
                    webrtc = new SimpleWebRTC({
                        localVideoEl: 'self',
                        remoteVideosEl: 'caller',
                        autoRequestMedia: true,
                        url: uiModel.getSignalingSocketEndpoint(), // gives my own signaling server URL
                        enableDataChannels: false,
                        debug: true
                    });

                    // Join the room once SimpleWebRTC is ready
                    webrtc.on('readyToCall', function () {
                        webrtc.joinRoom(roomName);
                    });
                } else {
                    webrtc.startLocalVideo();
                    webrtc.joinRoom(roomName);
                }
                break;
            case 'hangup':
                webrtc.stopLocalVideo();
                webrtc.leaveRoom();
                break;
        }
    });
Bastian Heist
@beheist
Jun 21 2016 14:01
Hah, figured it out. It's a bit lengthy to post here, if anyone is interested do contact me via github or twitter.