Fixes issues with unloading the page

This commit is contained in:
hristoterezov 2016-01-04 14:55:43 -06:00
parent 3168c86f77
commit 95b23f994c
2 changed files with 9 additions and 9 deletions

15
app.js
View File

@ -210,12 +210,12 @@ function initConference(localTracks, connection) {
room.on(ConferenceEvents.USER_JOINED, function (id, user) {
console.error('USER %s connnected', id, user);
console.log('USER %s connnected', id, user);
// FIXME email???
APP.UI.addUser(id, user.getDisplayName());
});
room.on(ConferenceEvents.USER_LEFT, function (id, user) {
console.error('USER %s LEFT', id, user);
console.log('USER %s LEFT', id, user);
APP.UI.removeUser(id, user.getDisplayName());
APP.UI.stopPrezi(id);
});
@ -254,7 +254,7 @@ function initConference(localTracks, connection) {
if (track.isLocal()) { // skip local tracks
return;
}
console.error(
console.log(
'REMOTE %s TRACK', track.getType(), track.getParticipantId()
);
APP.UI.addRemoteStream(track);
@ -264,7 +264,7 @@ function initConference(localTracks, connection) {
return;
}
console.error(
console.log(
'REMOTE %s TRACK REMOVED', track.getType(), track.getParticipantId()
);
@ -556,9 +556,12 @@ function initConference(localTracks, connection) {
}
);
$(window).bind('beforeunload', function () {
const unload = () => {
room.leave();
});
connection.disconnect();
};
$(window).bind('beforeunload', unload );
$(window).bind('unload', unload );
return new Promise(function (resolve, reject) {
room.on(ConferenceEvents.CONFERENCE_JOINED, handleConferenceJoined);

View File

@ -6289,7 +6289,6 @@ ChatRoom.prototype.createNonAnonymousRoom = function () {
};
ChatRoom.prototype.onPresence = function (pres) {
console.log(pres);
var from = pres.getAttribute('from');
// Parse roles.
var member = {};
@ -6326,7 +6325,6 @@ ChatRoom.prototype.onPresence = function (pres) {
if (displayName && displayName.length > 0) {
this.eventEmitter.emit(XMPPEvents.DISPLAY_NAME_CHANGED, from, displayName);
}
logger.info("Display name: " + displayName, pres);
}
break;
case "userId":
@ -6345,7 +6343,6 @@ ChatRoom.prototype.onPresence = function (pres) {
var jibri = node;
break;
case "call-control":
console.log(pres);
var att = node.attributes;
if(!att)
break;