muaz-khan/WebRTC-Scalable-Broadcast

bug report of webrtc-scalable-broadcast

Jackie2016 opened this issue · 0 comments

hi,nice muaz-khan
i find a bug in share-files.html or maybe in rtcmulticonnection.js.
i make a connect network like this at first:
peer 1<--peer 2<--peer 3
peer2 request file from peer1
peer3 request file from peer2
then i close peer 3
at this time,i transfer png file from peer1 to peer2.but the peer2 could not show the png image,only show 100% with the progressbar.

also,i do many similar experiments to test it,it is same on different connect network.
i trace the code,and find the bugs in share-files.html:

...
        var div = helper.div;
        if (file.type.indexOf('image') != -1) {
            div.innerHTML = '<a href="' + file.url + '" download="' + file.name + '">Download <strong style="color:red;">' + file.name + '</strong> </a><br /><img src="' + file.url + '" title="' + file.name + '" style="max-width: 80%;">';
        } else if (file.type.indexOf('video/') != -1) {
            div.innerHTML = '<a href="' + file.url + '" download="' + file.name + '">Download <strong style="color:red;">' + file.name + '</strong> </a><br /><video src="' + file.url + '" title="' + file.name + '" style="max-width: 80%;" controls></video>';
        } else if (file.type.indexOf('audio/') != -1) {
            div.innerHTML = '<a href="' + file.url + '" download="' + file.name + '">Download <strong style="color:red;">' + file.name + '</strong> </a><br /><audio src="' + file.url + '" title="' + file.name + '" style="max-width: 80%;" controls></audio>';
        } else {
            div.innerHTML = '<a href="' + file.url + '" download="' + file.name + '">Download <strong style="color:red;">' + file.name + '</strong> </a><br /><iframe src="' + file.url + '" title="' + file.name + '" style="width: 80%;border: 0;height: inherit;margin-top:1em;"></iframe>';
        }

        if(connection.broadcastingConnection && connection.broadcastingConnection.numberOfConnectedUsers > 0) {
             connection.broadcastingConnection.send(file);
        }
...

if i close peer3,the connection.broadcastingConnection.numberOfConnectedUsers has not decreased 1,so in fact,the real connection.broadcastingConnection.numberOfConnectedUsers is 0 but your code here connection.broadcastingConnection.numberOfConnectedUsers is still 1.it is not correct.
so the bugs happen.
i don't know how to rectify it.could you help to remove the bugs?
by the way,i do the experiment on three tab of firefox.i have only one PC.i dont know whether the bugs will happen when i do the same experiment on three PC.
could you give me some ideas?thanks