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){
|
$.get((window.location.href + '/request').replace('#', ''), function(data){
|
||||||
meetings = data['meetings']
|
meetings = data['meetings']
|
||||||
for(var i = 0; i < meetings.length; i++){
|
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']
|
name = meetings[i]['meetingName']
|
||||||
participants = parseInt(meetings[i]['participantCount'])
|
participants = parseInt(meetings[i]['participantCount'])
|
||||||
moderators = parseInt(meetings[i]['moderatorCount'])
|
moderators = parseInt(meetings[i]['moderatorCount'])
|
||||||
|
@ -87,7 +89,7 @@ renderActiveMeeting = function(m){
|
||||||
|
|
||||||
// Set up join on click.
|
// Set up join on click.
|
||||||
meeting_item.click(function(){
|
meeting_item.click(function(){
|
||||||
joinMeeting(name);
|
joinMeeting(m['name']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,12 +101,10 @@ removeActiveMeeting = function(meeting){
|
||||||
|
|
||||||
// Directly join a meeting from active meetings.
|
// Directly join a meeting from active meetings.
|
||||||
joinMeeting = function(meeting_name){
|
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().setUserName(localStorage.getItem('lastJoinedName'));
|
||||||
Meeting.getInstance().setMeetingId(meeting_name);
|
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();
|
var jqxhr = Meeting.getInstance().getJoinMeetingResponse();
|
||||||
if (jqxhr) {
|
if (jqxhr) {
|
||||||
jqxhr.done(function(data) {
|
jqxhr.done(function(data) {
|
||||||
|
@ -120,11 +120,6 @@ joinMeeting = function(meeting_name){
|
||||||
} else {
|
} else {
|
||||||
$('.meeting-user-name').parent().addClass('has-error');
|
$('.meeting-user-name').parent().addClass('has-error');
|
||||||
}
|
}
|
||||||
|
|
||||||
// if not user name was set it means we must ask for a name
|
|
||||||
} else {
|
|
||||||
$(location).attr("href", Meeting.getInstance().getURL());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only need to register for logged in users.
|
// Only need to register for logged in users.
|
||||||
|
@ -137,8 +132,8 @@ $(document).on('turbolinks:load', function(){
|
||||||
if(!App.messages){
|
if(!App.messages){
|
||||||
App.messages = App.cable.subscriptions.create('RefreshMeetingsChannel', {
|
App.messages = App.cable.subscriptions.create('RefreshMeetingsChannel', {
|
||||||
received: function(data) {
|
received: function(data) {
|
||||||
console.log('Recieved ' + data['method'] + ' action for ' + data['meeting'] + '.')
|
console.log('Recieved ' + data['method'] + ' action for ' + data['meeting'] + ' with room id ' + data['room'] + '.')
|
||||||
if(isPreviouslyJoined(data['meeting'])){
|
if(isPreviouslyJoined(data['meeting']) && data['room'] == $('body').data('current-user')){
|
||||||
if(data['method'] == 'create'){
|
if(data['method'] == 'create'){
|
||||||
// Create an empty meeting.
|
// Create an empty meeting.
|
||||||
MEETINGS[data['meeting']] = {'name': data['meeting'],
|
MEETINGS[data['meeting']] = {'name': data['meeting'],
|
||||||
|
|
|
@ -290,13 +290,13 @@ class BbbController < ApplicationController
|
||||||
end
|
end
|
||||||
elsif eventName == "meeting_created_message"
|
elsif eventName == "meeting_created_message"
|
||||||
# Fire an Actioncable event that updates _previously_joined for the client.
|
# 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"
|
elsif eventName == "meeting_destroyed_event"
|
||||||
actioncable_event('destroy', params['id'])
|
actioncable_event('destroy', params['id'], params['room_id'])
|
||||||
elsif eventName == "user_joined_message"
|
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"
|
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
|
else
|
||||||
logger.info "Callback event will not be treated. Event name: #{eventName}"
|
logger.info "Callback event will not be treated. Event name: #{eventName}"
|
||||||
end
|
end
|
||||||
|
@ -304,10 +304,11 @@ class BbbController < ApplicationController
|
||||||
render head(:ok) && return
|
render head(:ok) && return
|
||||||
end
|
end
|
||||||
|
|
||||||
def actioncable_event(method, id, role = 'none')
|
def actioncable_event(method, id, room_id, role = 'none')
|
||||||
ActionCable.server.broadcast 'refresh_meetings',
|
ActionCable.server.broadcast 'refresh_meetings',
|
||||||
method: method,
|
method: method,
|
||||||
meeting: id,
|
meeting: id,
|
||||||
|
room: room_id,
|
||||||
role: role
|
role: role
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue