Skip to content

Commit 3fc09fd

Browse files
authored
Fixed bugs for sprint 1 (#141)
* fixed grammar error * QBWEBSDK-290 * up tests (set custom interval to all async. methods) * upd dataSpec also * QBWEBSDK-276 * QBWEBSDK-270 * change to enum * QBWEBSDK-278 * remove console
1 parent 15d08ea commit 3fc09fd

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

samples/webrtc/js/app.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -554,19 +554,25 @@
554554
console.group('onCallStatsReport');
555555
console.log('userId: ', userId);
556556
console.log('session: ', session);
557+
console.log('stats: ', stats);
557558
console.groupEnd();
558559

559560
/**
560561
* Hack for Firefox
561562
* (https://bugzilla.mozilla.org/show_bug.cgi?id=852665)
562563
*/
563564
if(is_firefox) {
564-
var inboundrtp = _.findWhere(stats, {type: 'inboundrtp'});
565+
var inboundrtp = _.findWhere(stats, {'type': 'inboundrtp'});
565566

566-
if(!inboundrtp || !app.helpers.isBytesReceivedChanges(userId, inboundrtp)) {
567+
if(!app.helpers.isBytesReceivedChanges(userId, inboundrtp)) {
567568
console.warn('This is Firefox and user ' + userId + ' has lost his connection.');
568569

569-
if(!_.isEmpty(app.currentSession)) {
570+
/**
571+
* 2 - This is how many stats
572+
* we can get without inboundrtp
573+
* before close connection
574+
*/
575+
if(app.network[userId].count >= 2 && !_.isEmpty(app.currentSession)) {
570576
app.currentSession.closeConnection(userId);
571577
app.helpers.notifyIfUserLeaveCall(session, userId, 'disconnected', 'Disconnected');
572578
}
@@ -713,7 +719,6 @@
713719
var state = app.currentSession.connectionStateForUser(userId),
714720
peerConnList = QB.webrtc.PeerConnectionState;
715721

716-
717722
if(state === peerConnList.DISCONNECTED || state === peerConnList.FAILED || state === peerConnList.CLOSED) {
718723
return false;
719724
}

samples/webrtc/js/helpers.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,20 @@
1111

1212
app.helpers.isBytesReceivedChanges = function(userId, inboundrtp) {
1313
var res = true,
14-
inbBytesRec = inboundrtp.bytesReceived;
14+
inbBytesRec = inboundrtp ? inboundrtp.bytesReceived : 0;
1515

16-
if(app.network[userId] === undefined) {
16+
if(app.network[userId] || !inboundrtp) {
1717
app.network[userId] = {
18-
'bytesReceived': inbBytesRec
18+
'bytesReceived': inbBytesRec,
19+
'count': 0
1920
};
2021
} else {
2122
if(app.network[userId].bytesReceived === inbBytesRec) {
2223
res = false;
2324
} else {
2425
app.network[userId] = {
25-
'bytesReceived': inbBytesRec
26+
'bytesReceived': inbBytesRec,
27+
'count': ++app.network[userId].count
2628
};
2729
}
2830
}

0 commit comments

Comments
 (0)