forked from External/greenlight
make active meetings room specific
This commit is contained in:
parent
91499ff2e5
commit
261bb314f2
|
@ -51,6 +51,8 @@ initialPopulate = function(){
|
|||
$.get((window.location.href + '/request').replace('#', ''), function(data){
|
||||
meetings = data['meetings']
|
||||
for(var i = 0; i < meetings.length; i++){
|
||||
// Make sure the meeting actually belongs to the current user.
|
||||
if(meetings[i]['metadata']['room-id'] != $('body').data('current-user')) { continue; }
|
||||
name = meetings[i]['meetingName']
|
||||
participants = parseInt(meetings[i]['participantCount'])
|
||||
moderators = parseInt(meetings[i]['moderatorCount'])
|
||||
|
@ -87,7 +89,7 @@ renderActiveMeeting = function(m){
|
|||
|
||||
// Set up join on click.
|
||||
meeting_item.click(function(){
|
||||
joinMeeting(name);
|
||||
joinMeeting(m['name']);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -99,31 +101,24 @@ removeActiveMeeting = function(meeting){
|
|||
|
||||
// Directly join a meeting from active meetings.
|
||||
joinMeeting = function(meeting_name){
|
||||
var name = $('.meeting-user-name').val();
|
||||
if (meeting_name == undefined || meeting_name == null) { return; }
|
||||
Meeting.getInstance().setUserName(localStorage.getItem('lastJoinedName'));
|
||||
Meeting.getInstance().setMeetingId(meeting_name);
|
||||
|
||||
// a user name is set, join the user into the session
|
||||
if (name !== undefined && name !== null) {
|
||||
var jqxhr = Meeting.getInstance().getJoinMeetingResponse();
|
||||
if (jqxhr) {
|
||||
jqxhr.done(function(data) {
|
||||
if (data.messageKey === 'wait_for_moderator') {
|
||||
waitForModerator(Meeting.getInstance().getURL());
|
||||
} else {
|
||||
$(location).attr("href", data.response.join_url);
|
||||
}
|
||||
});
|
||||
jqxhr.fail(function(xhr, status, error) {
|
||||
console.info("meeting join failed");
|
||||
});
|
||||
} else {
|
||||
$('.meeting-user-name').parent().addClass('has-error');
|
||||
}
|
||||
|
||||
// if not user name was set it means we must ask for a name
|
||||
var jqxhr = Meeting.getInstance().getJoinMeetingResponse();
|
||||
if (jqxhr) {
|
||||
jqxhr.done(function(data) {
|
||||
if (data.messageKey === 'wait_for_moderator') {
|
||||
waitForModerator(Meeting.getInstance().getURL());
|
||||
} else {
|
||||
$(location).attr("href", data.response.join_url);
|
||||
}
|
||||
});
|
||||
jqxhr.fail(function(xhr, status, error) {
|
||||
console.info("meeting join failed");
|
||||
});
|
||||
} else {
|
||||
$(location).attr("href", Meeting.getInstance().getURL());
|
||||
$('.meeting-user-name').parent().addClass('has-error');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,8 +132,8 @@ $(document).on('turbolinks:load', function(){
|
|||
if(!App.messages){
|
||||
App.messages = App.cable.subscriptions.create('RefreshMeetingsChannel', {
|
||||
received: function(data) {
|
||||
console.log('Recieved ' + data['method'] + ' action for ' + data['meeting'] + '.')
|
||||
if(isPreviouslyJoined(data['meeting'])){
|
||||
console.log('Recieved ' + data['method'] + ' action for ' + data['meeting'] + ' with room id ' + data['room'] + '.')
|
||||
if(isPreviouslyJoined(data['meeting']) && data['room'] == $('body').data('current-user')){
|
||||
if(data['method'] == 'create'){
|
||||
// Create an empty meeting.
|
||||
MEETINGS[data['meeting']] = {'name': data['meeting'],
|
||||
|
|
|
@ -290,13 +290,13 @@ class BbbController < ApplicationController
|
|||
end
|
||||
elsif eventName == "meeting_created_message"
|
||||
# Fire an Actioncable event that updates _previously_joined for the client.
|
||||
actioncable_event('create', params['id'])
|
||||
actioncable_event('create', params['id'], params['room_id'])
|
||||
elsif eventName == "meeting_destroyed_event"
|
||||
actioncable_event('destroy', params['id'])
|
||||
actioncable_event('destroy', params['id'], params['room_id'])
|
||||
elsif eventName == "user_joined_message"
|
||||
actioncable_event('join', params['id'], event['payload']['user']['role'])
|
||||
actioncable_event('join', params['id'], params['room_id'], event['payload']['user']['role'])
|
||||
elsif eventName == "user_left_message"
|
||||
actioncable_event('leave', params['id'], event['payload']['user']['role'])
|
||||
actioncable_event('leave', params['id'], params['room_id'], event['payload']['user']['role'])
|
||||
else
|
||||
logger.info "Callback event will not be treated. Event name: #{eventName}"
|
||||
end
|
||||
|
@ -304,10 +304,11 @@ class BbbController < ApplicationController
|
|||
render head(:ok) && return
|
||||
end
|
||||
|
||||
def actioncable_event(method, id, role = 'none')
|
||||
def actioncable_event(method, id, room_id, role = 'none')
|
||||
ActionCable.server.broadcast 'refresh_meetings',
|
||||
method: method,
|
||||
meeting: id,
|
||||
room: room_id,
|
||||
role: role
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue