Makes "authentication required" dialog persistent. Joins the room if someone else authenticates first and creates the conference for us.
This commit is contained in:
parent
2494444ca4
commit
cd0c9393d8
80
app.js
80
app.js
|
@ -2,7 +2,12 @@
|
||||||
/* application specific logic */
|
/* application specific logic */
|
||||||
var connection = null;
|
var connection = null;
|
||||||
var authenticatedUser = false;
|
var authenticatedUser = false;
|
||||||
|
/* Popup window that show login page */
|
||||||
var authenticationWindow = null;
|
var authenticationWindow = null;
|
||||||
|
/* Initial "authentication required" dialog */
|
||||||
|
var authDialog = null;
|
||||||
|
/* Loop retry ID that wits for other user to create the room */
|
||||||
|
var authRetryId = null;
|
||||||
var activecall = null;
|
var activecall = null;
|
||||||
var nickname = null;
|
var nickname = null;
|
||||||
var sharedKey = '';
|
var sharedKey = '';
|
||||||
|
@ -187,6 +192,17 @@ function doJoin() {
|
||||||
|
|
||||||
function doJoinAfterFocus() {
|
function doJoinAfterFocus() {
|
||||||
|
|
||||||
|
// Close authentication dialog if opened
|
||||||
|
if (authDialog) {
|
||||||
|
messageHandler.closeDialog();
|
||||||
|
authDialog = null;
|
||||||
|
}
|
||||||
|
// Clear retry interval, so that we don't call 'doJoinAfterFocus' twice
|
||||||
|
if (authRetryId) {
|
||||||
|
window.clearTimeout(authRetryId);
|
||||||
|
authRetryId = null;
|
||||||
|
}
|
||||||
|
|
||||||
var roomjid;
|
var roomjid;
|
||||||
roomjid = roomName;
|
roomjid = roomName;
|
||||||
|
|
||||||
|
@ -879,38 +895,62 @@ $(document).bind('passwordrequired.main', function (event) {
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).bind('auth_required.moderator', function () {
|
$(document).bind('auth_required.moderator', function () {
|
||||||
|
|
||||||
|
// This is the loop that will wait for the room to be created by
|
||||||
|
// someone else. 'auth_required.moderator' will bring us back here.
|
||||||
|
authRetryId = window.setTimeout(
|
||||||
|
function () {
|
||||||
|
Moderator.allocateConferenceFocus(roomName, doJoinAfterFocus);
|
||||||
|
}, 5000);
|
||||||
|
// Show prompt only if it's not open
|
||||||
|
if (authDialog !== null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// extract room name from 'room@muc.server.net'
|
// extract room name from 'room@muc.server.net'
|
||||||
var room = roomName.substr(0, roomName.indexOf('@'));
|
var room = roomName.substr(0, roomName.indexOf('@'));
|
||||||
|
|
||||||
messageHandler.openDialog(
|
authDialog = messageHandler.openDialog(
|
||||||
'Stop',
|
'Stop',
|
||||||
'Authentication is required to create room:<br/>' + room,
|
'Authentication is required to create room:<br/><b>' + room +
|
||||||
|
'</b></br> You can either authenticate to create the room or ' +
|
||||||
|
'just wait for someone else to do so.',
|
||||||
true,
|
true,
|
||||||
{
|
{
|
||||||
Authenticate: 'authNow',
|
Authenticate: 'authNow'
|
||||||
Close: 'close'
|
|
||||||
},
|
},
|
||||||
function (onSubmitEvent, submitValue) {
|
function (onSubmitEvent, submitValue) {
|
||||||
console.info('On submit: ' + submitValue, submitValue);
|
|
||||||
|
// Do not close the dialog yet
|
||||||
|
onSubmitEvent.preventDefault();
|
||||||
|
|
||||||
|
// Open login popup
|
||||||
if (submitValue === 'authNow') {
|
if (submitValue === 'authNow') {
|
||||||
authenticateClicked();
|
authenticateClicked();
|
||||||
} else {
|
|
||||||
Toolbar.showAuthenticateButton(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
function authenticateClicked() {
|
function authenticateClicked() {
|
||||||
|
// If auth window exists just bring it to the front
|
||||||
|
if (authenticationWindow) {
|
||||||
|
authenticationWindow.focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Get authentication URL
|
// Get authentication URL
|
||||||
Moderator.getAuthUrl(function (url) {
|
Moderator.getAuthUrl(function (url) {
|
||||||
// Open popup with authentication URL
|
// Open popup with authentication URL
|
||||||
authenticationWindow = messageHandler.openCenteredPopup(
|
authenticationWindow = messageHandler.openCenteredPopup(
|
||||||
url, 910, 660,
|
url, 910, 660,
|
||||||
|
// On closed
|
||||||
function () {
|
function () {
|
||||||
|
// Close authentication dialog if opened
|
||||||
|
if (authDialog) {
|
||||||
|
messageHandler.closeDialog();
|
||||||
|
authDialog = null;
|
||||||
|
}
|
||||||
// On popup closed - retry room allocation
|
// On popup closed - retry room allocation
|
||||||
Moderator.allocateConferenceFocus(
|
Moderator.allocateConferenceFocus(roomName, doJoinAfterFocus);
|
||||||
roomName, doJoinAfterFocus);
|
|
||||||
authenticationWindow = null;
|
authenticationWindow = null;
|
||||||
});
|
});
|
||||||
if (!authenticationWindow) {
|
if (!authenticationWindow) {
|
||||||
|
@ -1587,21 +1627,15 @@ function hangup() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$.prompt("Session Terminated",
|
messageHandler.openDialog(
|
||||||
|
"Session Terminated",
|
||||||
|
"You hung up the call",
|
||||||
|
true,
|
||||||
|
{ "Join again": true },
|
||||||
|
function(event, value, message, formVals)
|
||||||
{
|
{
|
||||||
title: "You hung up the call",
|
window.location.reload();
|
||||||
persistent: true,
|
return false;
|
||||||
buttons: {
|
|
||||||
"Join again": true
|
|
||||||
},
|
|
||||||
closeText: '',
|
|
||||||
submit: function(event, value, message, formVals)
|
|
||||||
{
|
|
||||||
window.location.reload();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* global $, jQuery */
|
||||||
var messageHandler = (function(my) {
|
var messageHandler = (function(my) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,15 +54,27 @@ var messageHandler = (function(my) {
|
||||||
* @param submitFunction function to be called on submit
|
* @param submitFunction function to be called on submit
|
||||||
* @param loadedFunction function to be called after the prompt is fully loaded
|
* @param loadedFunction function to be called after the prompt is fully loaded
|
||||||
*/
|
*/
|
||||||
my.openDialog = function(titleString, msgString, persistent, buttons, submitFunction, loadedFunction) {
|
my.openDialog = function (titleString, msgString, persistent, buttons,
|
||||||
$.prompt(msgString, {
|
submitFunction, loadedFunction) {
|
||||||
|
var args = {
|
||||||
title: titleString,
|
title: titleString,
|
||||||
persistent: false,
|
persistent: persistent,
|
||||||
buttons: buttons,
|
buttons: buttons,
|
||||||
defaultButton: 1,
|
defaultButton: 1,
|
||||||
loaded: loadedFunction,
|
loaded: loadedFunction,
|
||||||
submit: submitFunction
|
submit: submitFunction
|
||||||
});
|
};
|
||||||
|
if (persistent) {
|
||||||
|
args.closeText = '';
|
||||||
|
}
|
||||||
|
return $.prompt(msgString, args);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes currently opened dialog.
|
||||||
|
*/
|
||||||
|
my.closeDialog = function () {
|
||||||
|
$.prompt.close();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue