first check if the html5 client is running and then attempt to redirect the user

This commit is contained in:
Anton Georgiev 2015-03-06 22:44:13 +00:00
parent deec36b411
commit ee69c62309

View File

@ -82,34 +82,63 @@
<script type="text/javascript">
function html5() {
// no Flash detected on the client
// use the enter api to detect the meetingid, userid and authToken
// for the attempted joining of the meeting
// and reuse them to join via the HTML5 client
var request = $.ajax({
var originalPath, request;
originalPath = document.location.pathname;
checkRequest = $.ajax({
dataType: 'json',
url: '/bigbluebutton/api/enter'
url: '/html5client/check'
});
request.done(function(data) {
var authToken, meetingId, userId;
meetingId = data.response.meetingID;
userId = data.response.externUserID;
authToken = data.response.authToken;
if ((meetingId != null) && (userId != null) && (authToken != null)) {
// redirect to the html5 client with the received info
// format <IP>/html5client/<meetingId>/<userId>/<authToken>
document.location.pathname = "/html5client/"+meetingId+"/"+userId+"/"+authToken;
} else {
// redirect to the logout URL
document.location=data.response.logoutUrl;
}
checkRequest.done(function(data) {
// Currently the request always fails but with different error
// depending on whether the meteor process is running or not
// see how we handle the failing case:
});
request.fail(function(data, textStatus, errorThrown){
BBBLog.error("Could not redirect to html5client (Flash not detected)");
checkRequest.fail(function(data, textStatus, errorThrown){
// if the errorThrown is "Not Found" -> the meteor process is not running
// [else] if the errorThrown is "parseError" - it is running.
if(errorThrown != "Not Found") {
// use the enter api to detect the meetingid, userid and authToken
// for the attempted joining of the meeting
// and reuse them to join via the HTML5 client
enterRequest = $.ajax({
dataType: 'json',
url: '/bigbluebutton/api/enter'
});
enterRequest.done(function(data) {
var authToken, meetingId, userId;
meetingId = data.response.meetingID;
userId = data.response.externUserID;
authToken = data.response.authToken;
if ((meetingId != null) && (userId != null) && (authToken != null)) {
// redirect to the html5 client with the received info
// format <IP>/html5client/<meetingId>/<userId>/<authToken>
document.location.pathname = "/html5client/"+meetingId+"/"+userId+"/"+authToken;
} else {
// go back to the redirection page
document.location.pathname = originalPath;
}
});
enterRequest.fail(function(data, textStatus, errorThrown){
BBBLog.error("Could not redirect to html5client (Flash not detected)");
});
}
else {
alert("Unable to load the HTML5 client!");
BBBLog.error("Could not redirect to html5client (the server side does not seem to be running)");
}
});
}
</script>
</head>