From e74d27bf88f9f5abe17597bb914da538ea8dc11f Mon Sep 17 00:00:00 2001 From: George Politis Date: Thu, 2 Oct 2014 19:11:55 +0200 Subject: [PATCH] Selects the datachannel that is ready for sending notifications to the bridge. --- app.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app.js b/app.js index 13dcea83e..50ab11b76 100644 --- a/app.js +++ b/app.js @@ -1507,12 +1507,20 @@ $(document).bind('fatalError.jingle', function onSelectedEndpointChanged(userJid) { console.log('selected endpoint changed: ', userJid); - if (_dataChannels && _dataChannels.length != 0 && _dataChannels[0].readyState == "open") { - _dataChannels[0].send(JSON.stringify({ - 'colibriClass': 'SelectedEndpointChangedEvent', - 'selectedEndpoint': (!userJid || userJid == null) - ? null : Strophe.getResourceFromJid(userJid) - })); + if (_dataChannels && _dataChannels.length != 0) + { + _dataChannels.some(function (dataChannel) { + if (dataChannel.readyState == 'open') + { + dataChannel.send(JSON.stringify({ + 'colibriClass': 'SelectedEndpointChangedEvent', + 'selectedEndpoint': (!userJid || userJid == null) + ? null : Strophe.getResourceFromJid(userJid) + })); + + return true; + } + }); } }