RTCMultiConnection icon indicating copy to clipboard operation
RTCMultiConnection copied to clipboard

How check if connection created

Open Vladislavlr opened this issue 3 years ago • 2 comments
trafficstars

How i can check if broadcast exist? ` var broadcastId = "stream_"+recipientId; if (broadcastId.replace(/^\s+|\s+$/g, '').length <= 0) { alert('Please enter broadcast-id'); document.getElementById('broadcast-id').focus(); return; }

connection.extra.broadcastId = broadcastId;

connection.session = {
    audio: {
        autoGainControl: false,
        echoCancellation: false,
        googAutoGainControl: false,
        noiseSuppression: false,
    },
    video: true,
    oneway: true
};

connection.getSocket(function (socket) {
    socket.emit('check-broadcast-presence', broadcastId, function (isBroadcastExists) {
        if (!isBroadcastExists) {

            //disableBroadcastVideo();
            //return false;
            connection.userid = broadcastId;
        }

        console.log('check-broadcast-presence', broadcastId, isBroadcastExists);

        socket.emit('join-broadcast', {
            broadcastId: broadcastId,
            userid: connection.userid,
            typeOfStreams: connection.session
        });
    });
});`

Vladislavlr avatar Jun 29 '22 19:06 Vladislavlr

I want to check if the room is already created

Vladislavlr avatar Jun 29 '22 19:06 Vladislavlr

Hello!

You can check if a room exists with the following code:

connection.checkPresence(ROOM_ID, function (isRoomExist) {
             if (isRoomExist) {
                   console.log("ROOM EXIST")
                } else {
       	           console.log("ROOM NOT EXIST")
             }
});

Cheers

MediaKitApp avatar Oct 07 '22 14:10 MediaKitApp