2016-01-13 04:15:16 +08:00
|
|
|
this.Router.configure({
|
2016-03-14 09:46:29 +08:00
|
|
|
layoutTemplate: 'layout',
|
2016-01-13 04:15:16 +08:00
|
|
|
});
|
|
|
|
|
2016-03-14 09:46:29 +08:00
|
|
|
this.Router.map(function () {
|
2016-01-15 13:46:41 +08:00
|
|
|
// this is how we handle login attempts
|
2016-03-14 09:46:29 +08:00
|
|
|
this.route('main', {
|
|
|
|
path: '/html5client/:meeting_id/:user_id/:auth_token',
|
|
|
|
where: 'client',
|
2016-01-13 04:15:16 +08:00
|
|
|
onBeforeAction() {
|
|
|
|
let applyNewSessionVars, authToken, meetingId, userId;
|
|
|
|
meetingId = this.params.meeting_id;
|
|
|
|
userId = this.params.user_id;
|
|
|
|
authToken = this.params.auth_token;
|
2016-03-14 09:46:29 +08:00
|
|
|
setInSession('loginUrl', this.originalUrl);
|
2016-01-15 13:46:41 +08:00
|
|
|
|
|
|
|
// catch if any of the user's meeting data is invalid
|
2016-01-13 04:15:16 +08:00
|
|
|
if ((authToken == null) || (meetingId == null) || (userId == null)) {
|
2016-01-15 13:46:41 +08:00
|
|
|
// if their data is invalid, redirect the user to the logout page
|
2016-01-13 04:15:16 +08:00
|
|
|
document.location = getInSession('logoutURL');
|
|
|
|
} else {
|
2016-03-14 09:46:29 +08:00
|
|
|
Meteor.call('validateAuthToken', meetingId, userId, authToken);
|
|
|
|
applyNewSessionVars = function () {
|
|
|
|
setInSession('authToken', authToken);
|
|
|
|
setInSession('meetingId', meetingId);
|
|
|
|
setInSession('userId', userId);
|
2016-01-13 04:15:16 +08:00
|
|
|
return Router.go('/html5client');
|
|
|
|
};
|
2016-03-14 09:46:29 +08:00
|
|
|
|
2016-01-13 04:15:16 +08:00
|
|
|
clearSessionVar(applyNewSessionVars);
|
|
|
|
}
|
2016-03-14 09:46:29 +08:00
|
|
|
|
2016-01-13 04:15:16 +08:00
|
|
|
return this.next();
|
2016-03-14 09:46:29 +08:00
|
|
|
},
|
2016-01-13 04:15:16 +08:00
|
|
|
});
|
2016-01-15 13:46:41 +08:00
|
|
|
|
|
|
|
// the user successfully logged in
|
2016-03-14 09:46:29 +08:00
|
|
|
this.route('signedin', {
|
|
|
|
path: '/html5client',
|
|
|
|
where: 'client',
|
2016-01-13 04:15:16 +08:00
|
|
|
action() {
|
|
|
|
let authToken, meetingId, onErrorFunction, userId;
|
2016-03-14 09:46:29 +08:00
|
|
|
meetingId = getInSession('meetingId');
|
|
|
|
userId = getInSession('userId');
|
|
|
|
authToken = getInSession('authToken');
|
|
|
|
onErrorFunction = function (error, result) {
|
|
|
|
console.log('ONERRORFUNCTION');
|
2016-01-15 13:46:41 +08:00
|
|
|
|
|
|
|
//make sure the user is not let through
|
2016-03-14 09:46:29 +08:00
|
|
|
Meteor.call('userLogout', meetingId, userId, authToken);
|
2016-01-15 13:46:41 +08:00
|
|
|
|
2016-01-13 04:15:16 +08:00
|
|
|
clearSessionVar();
|
2016-01-15 13:46:41 +08:00
|
|
|
|
|
|
|
// Attempt to log back in
|
2016-01-13 04:15:16 +08:00
|
|
|
if (error == null) {
|
|
|
|
window.location.href = getInSession('loginUrl') || getInSession('logoutURL');
|
|
|
|
}
|
|
|
|
};
|
2016-03-14 09:46:29 +08:00
|
|
|
|
2016-01-13 04:15:16 +08:00
|
|
|
Meteor.subscribe('chat', meetingId, userId, authToken, {
|
|
|
|
onError: onErrorFunction,
|
|
|
|
onReady: (_this => {
|
2016-03-14 09:46:29 +08:00
|
|
|
return function () {
|
2016-01-13 04:15:16 +08:00
|
|
|
return Meteor.subscribe('shapes', meetingId, {
|
2016-03-14 09:46:29 +08:00
|
|
|
onReady: function () {
|
2016-01-13 04:15:16 +08:00
|
|
|
return Meteor.subscribe('slides', meetingId, {
|
2016-03-14 09:46:29 +08:00
|
|
|
onReady: function () {
|
2016-01-13 04:15:16 +08:00
|
|
|
return Meteor.subscribe('meetings', meetingId, {
|
2016-03-14 09:46:29 +08:00
|
|
|
onReady: function () {
|
2016-01-13 04:15:16 +08:00
|
|
|
return Meteor.subscribe('presentations', meetingId, {
|
2016-03-14 09:46:29 +08:00
|
|
|
onReady: function () {
|
2016-01-13 04:15:16 +08:00
|
|
|
return Meteor.subscribe('users', meetingId, userId, authToken, {
|
|
|
|
onError: onErrorFunction,
|
2016-03-14 09:46:29 +08:00
|
|
|
onReady: function () {
|
2016-01-13 04:15:16 +08:00
|
|
|
return Meteor.subscribe('whiteboard-clean-status', meetingId, {
|
2016-03-14 09:46:29 +08:00
|
|
|
onReady: function () {
|
2016-01-13 04:15:16 +08:00
|
|
|
return Meteor.subscribe('bbb_poll', meetingId, userId, authToken, {
|
2016-03-14 09:46:29 +08:00
|
|
|
onReady: function () {
|
2016-01-13 04:15:16 +08:00
|
|
|
return Meteor.subscribe('bbb_cursor', meetingId, {
|
2016-03-14 09:46:29 +08:00
|
|
|
onReady: function () {
|
2016-01-13 04:15:16 +08:00
|
|
|
let a, handleLogourUrlError;
|
2016-03-14 09:46:29 +08:00
|
|
|
|
2016-01-15 13:46:41 +08:00
|
|
|
// done subscribing, start rendering the client and set default settings
|
2016-01-13 04:15:16 +08:00
|
|
|
_this.render('main');
|
|
|
|
onLoadComplete();
|
2016-03-14 09:46:29 +08:00
|
|
|
handleLogourUrlError = function () {
|
|
|
|
alert('Error: could not find the logoutURL');
|
|
|
|
setInSession('logoutURL', document.location.hostname);
|
2016-01-13 04:15:16 +08:00
|
|
|
};
|
2016-01-15 13:46:41 +08:00
|
|
|
|
|
|
|
// obtain the logoutURL
|
2016-01-13 04:15:16 +08:00
|
|
|
a = $.ajax({
|
|
|
|
dataType: 'json',
|
2016-03-14 09:46:29 +08:00
|
|
|
url: '/bigbluebutton/api/enter',
|
2016-01-13 04:15:16 +08:00
|
|
|
});
|
|
|
|
a.done(data => {
|
2016-01-15 13:46:41 +08:00
|
|
|
if (data.response.logoutURL != null) { // for a meeting with 0 users
|
2016-03-14 09:46:29 +08:00
|
|
|
setInSession('logoutURL', data.response.logoutURL);
|
2016-01-13 04:15:16 +08:00
|
|
|
} else {
|
2016-01-15 13:46:41 +08:00
|
|
|
if (data.response.logoutUrl != null) { // for a running meeting
|
2016-03-14 09:46:29 +08:00
|
|
|
setInSession('logoutURL', data.response.logoutUrl);
|
2016-01-13 04:15:16 +08:00
|
|
|
} else {
|
|
|
|
return handleLogourUrlError();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return a.fail((data, textStatus, errorThrown) => {
|
|
|
|
return handleLogourUrlError();
|
|
|
|
});
|
2016-03-14 09:46:29 +08:00
|
|
|
},
|
2016-01-13 04:15:16 +08:00
|
|
|
});
|
2016-03-14 09:46:29 +08:00
|
|
|
},
|
2016-01-13 04:15:16 +08:00
|
|
|
});
|
2016-03-14 09:46:29 +08:00
|
|
|
},
|
2016-01-13 04:15:16 +08:00
|
|
|
});
|
2016-03-14 09:46:29 +08:00
|
|
|
},
|
2016-01-13 04:15:16 +08:00
|
|
|
});
|
2016-03-14 09:46:29 +08:00
|
|
|
},
|
2016-01-13 04:15:16 +08:00
|
|
|
});
|
2016-03-14 09:46:29 +08:00
|
|
|
},
|
2016-01-13 04:15:16 +08:00
|
|
|
});
|
2016-03-14 09:46:29 +08:00
|
|
|
},
|
2016-01-13 04:15:16 +08:00
|
|
|
});
|
2016-03-14 09:46:29 +08:00
|
|
|
},
|
2016-01-13 04:15:16 +08:00
|
|
|
});
|
|
|
|
};
|
2016-03-14 09:46:29 +08:00
|
|
|
})(this),
|
2016-01-13 04:15:16 +08:00
|
|
|
});
|
|
|
|
return this.render('loading');
|
2016-03-14 09:46:29 +08:00
|
|
|
},
|
2016-01-13 04:15:16 +08:00
|
|
|
});
|
2016-01-15 13:46:41 +08:00
|
|
|
|
|
|
|
// endpoint - is the html5client running (ready to handle a user)
|
2016-01-13 04:15:16 +08:00
|
|
|
this.route('meteorEndpoint', {
|
|
|
|
path: '/check',
|
|
|
|
where: 'server',
|
|
|
|
action() {
|
|
|
|
this.response.writeHead(200, {
|
2016-03-14 09:46:29 +08:00
|
|
|
'Content-Type': 'application/json',
|
2016-01-13 04:15:16 +08:00
|
|
|
});
|
2016-01-15 13:46:41 +08:00
|
|
|
|
|
|
|
// reply that the html5client is running
|
2016-01-13 04:15:16 +08:00
|
|
|
this.response.end(JSON.stringify({
|
2016-03-14 09:46:29 +08:00
|
|
|
html5clientStatus: 'running',
|
2016-01-13 04:15:16 +08:00
|
|
|
}));
|
2016-03-14 09:46:29 +08:00
|
|
|
},
|
2016-01-13 04:15:16 +08:00
|
|
|
});
|
|
|
|
});
|