listen to CONNECTION_INTERRUPTED and CONNECTION_RESTORED events

This commit is contained in:
isymchych 2015-12-01 12:05:55 +02:00
parent c21c9ce1b8
commit 4152106a06
3 changed files with 32 additions and 10 deletions

28
app.js
View File

@ -119,7 +119,7 @@ function connect() {
connection.connect(); connection.connect();
}).catch(function (errType, msg) { }).catch(function (errType, msg) {
// TODO handle OTHER_ERROR only // TODO handle OTHER_ERROR only
UI.notifyConnectionFailed(msg); APP.UI.notifyConnectionFailed(msg);
// rethrow // rethrow
throw new Error(errType); throw new Error(errType);
@ -140,7 +140,7 @@ function initConference(connection, roomName) {
if (config.muteLocalVideoIfNotInLastN) { if (config.muteLocalVideoIfNotInLastN) {
// TODO mute or unmute if required // TODO mute or unmute if required
// mark video on UI // mark video on UI
// UI.markVideoMuted(true/false); // APP.UI.markVideoMuted(true/false);
} }
}); });
@ -160,7 +160,7 @@ function initConference(connection, roomName) {
room.on( room.on(
ConferenceEvents.DISPLAY_NAME_CHANGED, ConferenceEvents.DISPLAY_NAME_CHANGED,
function (id, displayName) { function (id, displayName) {
UI.changeDisplayName(id, displayName); APP.UI.changeDisplayName(id, displayName);
} }
); );
@ -168,14 +168,14 @@ function initConference(connection, roomName) {
ConferenceEvents.USER_JOINED, ConferenceEvents.USER_JOINED,
function (id) { function (id) {
// FIXME ???? // FIXME ????
UI.addUser(); APP.UI.addUser();
} }
); );
room.on( room.on(
ConferenceEvents.USER_LEFT, ConferenceEvents.USER_LEFT,
function (id) { function (id) {
UI.removeUser(id); APP.UI.removeUser(id);
} }
); );
@ -189,7 +189,21 @@ function initConference(connection, roomName) {
room.on( room.on(
ConferenceEvents.TRACK_AUDIO_LEVEL_CHANGED, ConferenceEvents.TRACK_AUDIO_LEVEL_CHANGED,
function (id, lvl) { 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() { function init() {
connect().then(function (connection) { connect().then(function (connection) {
return initConference(connection, UI.generateRoomName()); return initConference(connection, APP.UI.generateRoomName());
}).then(function (conference) { }).then(function (conference) {
APP.conference = conference; APP.conference = conference;

View File

@ -320,8 +320,8 @@ function chatSetSubject(text) {
return Chat.chatSetSubject(text); return Chat.chatSetSubject(text);
} }
function updateChatConversation(from, displayName, message, myjid, stamp) { function updateChatConversation(from, displayName, message, stamp) {
return Chat.updateChatConversation(from, displayName, message, myjid, stamp); return Chat.updateChatConversation(from, displayName, message, stamp);
} }
function initEtherpad(name) { function initEtherpad(name) {
@ -689,4 +689,12 @@ UI.showAuthenticateButton = function (show) {
Toolbar.showAuthenticateButton(show); Toolbar.showAuthenticateButton(show);
}; };
UI.markVideoInterrupted = function (interrupted) {
if (interrupted) {
VideoLayout.onVideoInterrupted();
} else {
VideoLayout.onVideoRestored();
}
};
module.exports = UI; module.exports = UI;

View File

@ -228,7 +228,7 @@ var Chat = (function (my) {
* Appends the given message to the chat conversation. * Appends the given message to the chat conversation.
*/ */
my.updateChatConversation = my.updateChatConversation =
function (from, displayName, message, myjid, stamp) { function (from, displayName, message, stamp) {
var divClassName = ''; var divClassName = '';
if (APP.xmpp.myJid() === from) { if (APP.xmpp.myJid() === from) {