From 4152106a06f165a6471be90be704c23c26a34a69 Mon Sep 17 00:00:00 2001 From: isymchych Date: Tue, 1 Dec 2015 12:05:55 +0200 Subject: [PATCH] listen to CONNECTION_INTERRUPTED and CONNECTION_RESTORED events --- app.js | 28 +++++++++++++++++++++------- modules/UI/UI.js | 12 ++++++++++-- modules/UI/side_pannels/chat/Chat.js | 2 +- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/app.js b/app.js index 90eaf4e2b..7580cf198 100644 --- a/app.js +++ b/app.js @@ -119,7 +119,7 @@ function connect() { connection.connect(); }).catch(function (errType, msg) { // TODO handle OTHER_ERROR only - UI.notifyConnectionFailed(msg); + APP.UI.notifyConnectionFailed(msg); // rethrow throw new Error(errType); @@ -140,7 +140,7 @@ function initConference(connection, roomName) { if (config.muteLocalVideoIfNotInLastN) { // TODO mute or unmute if required // mark video on UI - // UI.markVideoMuted(true/false); + // APP.UI.markVideoMuted(true/false); } }); @@ -160,7 +160,7 @@ function initConference(connection, roomName) { room.on( ConferenceEvents.DISPLAY_NAME_CHANGED, function (id, displayName) { - UI.changeDisplayName(id, displayName); + APP.UI.changeDisplayName(id, displayName); } ); @@ -168,14 +168,14 @@ function initConference(connection, roomName) { ConferenceEvents.USER_JOINED, function (id) { // FIXME ???? - UI.addUser(); + APP.UI.addUser(); } ); room.on( ConferenceEvents.USER_LEFT, function (id) { - UI.removeUser(id); + APP.UI.removeUser(id); } ); @@ -189,7 +189,21 @@ function initConference(connection, roomName) { room.on( ConferenceEvents.TRACK_AUDIO_LEVEL_CHANGED, function (id, lvl) { - UI.setAudioLevel(id, lvl); + APP.UI.setAudioLevel(id, lvl); + } + ); + + room.on( + ConferenceEvents.CONNECTION_INTERRUPTED, + function () { + APP.UI.markVideoInterrupted(true); + } + ); + + room.on( + ConferenceEvents.CONNECTION_RESTORED, + function () { + APP.UI.markVideoInterrupted(false); } ); @@ -219,7 +233,7 @@ function initConference(connection, roomName) { function init() { connect().then(function (connection) { - return initConference(connection, UI.generateRoomName()); + return initConference(connection, APP.UI.generateRoomName()); }).then(function (conference) { APP.conference = conference; diff --git a/modules/UI/UI.js b/modules/UI/UI.js index 25eb8edd6..c248639fa 100644 --- a/modules/UI/UI.js +++ b/modules/UI/UI.js @@ -320,8 +320,8 @@ function chatSetSubject(text) { return Chat.chatSetSubject(text); } -function updateChatConversation(from, displayName, message, myjid, stamp) { - return Chat.updateChatConversation(from, displayName, message, myjid, stamp); +function updateChatConversation(from, displayName, message, stamp) { + return Chat.updateChatConversation(from, displayName, message, stamp); } function initEtherpad(name) { @@ -689,4 +689,12 @@ UI.showAuthenticateButton = function (show) { Toolbar.showAuthenticateButton(show); }; +UI.markVideoInterrupted = function (interrupted) { + if (interrupted) { + VideoLayout.onVideoInterrupted(); + } else { + VideoLayout.onVideoRestored(); + } +}; + module.exports = UI; diff --git a/modules/UI/side_pannels/chat/Chat.js b/modules/UI/side_pannels/chat/Chat.js index 34f4b4e5d..ccf63373f 100644 --- a/modules/UI/side_pannels/chat/Chat.js +++ b/modules/UI/side_pannels/chat/Chat.js @@ -228,7 +228,7 @@ var Chat = (function (my) { * Appends the given message to the chat conversation. */ my.updateChatConversation = - function (from, displayName, message, myjid, stamp) { + function (from, displayName, message, stamp) { var divClassName = ''; if (APP.xmpp.myJid() === from) {