Skip to content

Commit eb25232

Browse files
Merge pull request #97 from rtc-io/check-channel-state
Check the data channel state in the channel monitor
2 parents 64e1e02 + 0557bf8 commit eb25232

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ module.exports = function (signalhost, opts) {
149149
var expectedLocalStreams = parseInt((opts || {}).expectedLocalStreams, 10) || 0;
150150
var announceTimer = 0;
151151
var updateTimer = 0;
152+
var CLOSED_STATES = ['failed', 'closed'];
152153

153154
function checkReadyToAnnounce() {
154155
clearTimeout(announceTimer);
@@ -402,9 +403,10 @@ module.exports = function (signalhost, opts) {
402403
if (channel.readyState === 'open') {
403404
channelReady();
404405
}
405-
// If the underlying connection has failed/closed, then terminate the monitor
406-
else if (['failed', 'closed'].indexOf(pc.iceConnectionState) !== -1) {
407-
debug('connection has terminated, cancelling channel monitor');
406+
// If the underlying connection has failed/closed, or if the ready state of the channel has transitioned to a closure
407+
// state, then terminate the monitor
408+
else if (CLOSED_STATES.indexOf(pc.iceConnectionState) !== -1 || CLOSED_STATES.indexOf(channel.readyState) !== -1) {
409+
debug('connection or channel has terminated, cancelling channel monitor');
408410
clearInterval(channelMonitor);
409411
clearTimeout(channelConnectionTimer);
410412
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"grunt-browserify": "^3.4.0",
4343
"grunt-contrib-uglify": "^0.9.1",
4444
"grunt-contrib-watch": "^0.6.1",
45+
"hosted-git-info": "2.5.0",
4546
"rtc-bufferedchannel": "^0.5.0",
4647
"rtc-captureconfig": "^2.1.0",
4748
"rtc-filter-grayscale": "~0.1.0",
@@ -55,4 +56,4 @@
5556
"uuid": "^2.0.1",
5657
"whisk": "^1.0.0"
5758
}
58-
}
59+
}

0 commit comments

Comments
 (0)