diff --git a/app/assets/javascripts/channels/meeting_updates.js b/app/assets/javascripts/channels/meeting_updates.js index f2d3664e..be34eaf4 100644 --- a/app/assets/javascripts/channels/meeting_updates.js +++ b/app/assets/javascripts/channels/meeting_updates.js @@ -1,5 +1,11 @@ (function() { + var sessionStatusRefresh = function(url) { + $.get(url + "/session_status_refresh", function(html) { + $(".join-form-wrapper").html(html); + }); + } + var initRooms = function() { App.messages = App.cable.subscriptions.create({ channel: 'MeetingUpdatesChannel', @@ -12,11 +18,12 @@ Meeting.getInstance().setModJoined(true); if (Meeting.getInstance().getWaitingForMod()) { loopJoin(); + } else { + sessionStatusRefresh($('.meeting-url').val()); } } - else if (data.action === 'meeting_ended') { - - } + } else if (data.action === 'meeting_ended') { + sessionStatusRefresh($('.meeting-url').val()); } } }); diff --git a/app/assets/javascripts/landing.js b/app/assets/javascripts/landing.js index 74c09a95..42e42055 100644 --- a/app/assets/javascripts/landing.js +++ b/app/assets/javascripts/landing.js @@ -15,7 +15,7 @@ var init = function() { - $('.meeting-join').click (function (event) { + $('.center-panel').on ('click', '.meeting-join', function (event) { var url = $('.meeting-url').val(); var name = $('.meeting-user-name').val(); Meeting.getInstance().setURL(url); @@ -34,7 +34,7 @@ }); }); - $('.meeting-end').click (function (event) { + $('.center-panel').on ('click', '.meeting-end', function (event) { var jqxhr = Meeting.getInstance().endMeeting(); var btn = $(this); btn.prop("disabled", true); @@ -46,7 +46,7 @@ }); }); - $('.meeting-url-copy').click (function (e) { + $('.center-panel').on ('click', '.meeting-url-copy', function (event) { meetingURL = $('.meeting-url'); meetingURL.select(); document.execCommand("copy"); diff --git a/app/controllers/bbb_controller.rb b/app/controllers/bbb_controller.rb index 4c9c24ec..f4eee6e4 100644 --- a/app/controllers/bbb_controller.rb +++ b/app/controllers/bbb_controller.rb @@ -43,6 +43,9 @@ class BbbController < ApplicationController load_and_authorize_room_owner! bbb_res = bbb_end_meeting @user.username + if bbb_res[:returncode] + EndMeetingJob.perform_later(@user.username) + end render_bbb_response bbb_res end diff --git a/app/controllers/landing_controller.rb b/app/controllers/landing_controller.rb index 5bae7175..e52e29c3 100644 --- a/app/controllers/landing_controller.rb +++ b/app/controllers/landing_controller.rb @@ -15,6 +15,17 @@ class LandingController < ApplicationController render layout: false end + def session_status_refresh + @user = User.find_by(username: params[:id]) + if @user.nil? + render head(:not_found) && return + end + + @meeting_running = bbb_get_meeting_info(@user.username)[:returncode] + + render layout: false + end + def admin? @user && @user == current_user end diff --git a/app/jobs/end_meeting_job.rb b/app/jobs/end_meeting_job.rb new file mode 100644 index 00000000..c0e6b718 --- /dev/null +++ b/app/jobs/end_meeting_job.rb @@ -0,0 +1,25 @@ +class EndMeetingJob < ApplicationJob + include BbbApi + + queue_as :default + + def perform(room) + tries = 0 + sleep_time = 2 + + while tries < 4 + bbb_res = bbb_get_meeting_info(room) + + if !bbb_res[:returncode] + ActionCable.server.broadcast "#{room}_meeting_updates_channel", + action: 'meeting_ended' + break + end + + sleep sleep_time + sleep_time = sleep_time * 2 + tries += 1 + end + + end +end diff --git a/app/views/landing/meetings.html.erb b/app/views/landing/meetings.html.erb index 8e927a57..311c1595 100644 --- a/app/views/landing/meetings.html.erb +++ b/app/views/landing/meetings.html.erb @@ -25,7 +25,7 @@ <%= render layout: 'shared/center_panel' do %>