fix recording update channel and routes

This commit is contained in:
Zachary Chai 2017-01-31 11:42:47 -05:00
parent c70ad42d8b
commit 9667e3757b
4 changed files with 33 additions and 15 deletions

View File

@ -62,13 +62,13 @@
};
$(document).on("turbolinks:load", function() {
// disable meeting updates if enabled from a previous page
if (App.meeting_update) {
disableMeetingUpdates();
}
if ($("body[data-controller=landing]").get(0)) {
if ($("body[data-action=rooms]").get(0)) {
// disable meeting updates if enabled from a previous page
if (App.meeting_update) {
disableMeetingUpdates();
}
if ($(".page-wrapper.rooms").data('main-room') === false) {
if (!$(".page-wrapper.rooms").data('main-room')) {
enableMeetingUpdates();
}
}

View File

@ -16,10 +16,11 @@
(function() {
var initRooms = function() {
App.messages = App.cable.subscriptions.create({
var enableRecordingUpdates = function() {
App.recording_update = App.cable.subscriptions.create({
channel: 'RecordingUpdatesChannel',
encrypted_id: $(".page-wrapper").data('id')
admin_id: $(".page-wrapper.rooms").data('admin-id'),
meeting_id: $(".page-wrapper.rooms").data('id')
},
{
received: function(data) {
@ -57,10 +58,19 @@
});
};
var disableRecordingUpdates = function() {
App.recording_update.unsubscribe();
delete App.recording_update
};
$(document).on("turbolinks:load", function() {
// disable recording updates if enabled from a previous page
if (App.recording_update) {
disableRecordingUpdates();
}
if ($("body[data-controller=landing]").get(0)) {
if ($("body[data-action=rooms]").get(0)) {
initRooms();
enableRecordingUpdates();
}
}
});

View File

@ -16,6 +16,11 @@
class RecordingUpdatesChannel < ApplicationCable::Channel
def subscribed
stream_from "#{params[:encrypted_id]}_recording_updates_channel"
full_id = if params[:meeting_id].present?
"#{params[:admin_id]}-#{params[:meeting_id]}"
else
params[:admin_id]
end
stream_from "#{full_id}_recording_updates_channel"
end
end

View File

@ -28,17 +28,20 @@ Rails.application.routes.draw do
# There are two resources [meetings|rooms]
# meetings offer a landing page for NON authenticated users to create and join session in BigBlueButton
# rooms offer a customized landing page for authenticated users to create and join session in BigBlueButton
get '/:resource/:id', to: 'landing#resource', as: :resource
get '/:resource/:id/join', to: 'bbb#join', as: :bbb_join, defaults: {format: 'json'}
get '/rooms/:room_id/recordings', to: 'bbb#recordings', defaults: {format: 'json'}
post '/:resource/:id/callback', to: 'bbb#callback' #, defaults: {format: 'json'}
patch '/rooms/:id/recordings/:record_id', to: 'bbb#update_recordings', defaults: {format: 'json'}
delete '/rooms/:id/recordings/:record_id', to: 'bbb#delete_recordings', defaults: {format: 'json'}
get '/rooms/:room_id/:id', to: 'landing#resource', resource: 'rooms'
get '/rooms/:room_id', to: 'landing#resource', resource: 'rooms'
delete '/rooms/:room_id/:id/end', to: 'bbb#end', defaults: {format: 'json'}
get '/:resource/:id', to: 'landing#resource', as: :resource
get '/:resource/:id/join', to: 'bbb#join', as: :bbb_join, defaults: {format: 'json'}
post '/:resource/:id/callback', to: 'bbb#callback' #, defaults: {format: 'json'}
get '/:resource/:room_id/:id/wait', to: 'landing#wait_for_moderator'
get '/:resource/:room_id/:id/session_status_refresh', to: 'landing#session_status_refresh'
delete '/rooms/:room_id/:id/end', to: 'bbb#end', defaults: {format: 'json'}
get '/rooms/:room_id/:id', to: 'landing#resource', resource: 'rooms'
get '/:resource/:room_id/:id/join', to: 'bbb#join', defaults: {format: 'json'}