Implemented join to BBB first approach

This commit is contained in:
jfederico
2016-10-17 18:36:56 -04:00
parent 682cbadbf0
commit f725b7f1bc
19 changed files with 182 additions and 10 deletions

View File

@ -1,2 +1,24 @@
module ApplicationHelper
def bbb_endpoint
logger.info APP_CONFIG
#if ((defined? APP_CONFIG).to_s == 'constant') && (APP_CONFIG.has_key?('bbb_endpoint'))
# APP_CONFIG['bbb_endpoint']
#else
'http://test-install.blindsidenetworks.com/bigbluebutton/'
#end
end
def bbb_secret
#if (defined? APP_CONFIG).to_s == 'constant' && (APP_CONFIG.has_key? 'bbb_secret')
# APP_CONFIG['bbb_secret']
#else
'8cd8ef52e8e101574e400365b55e11a6'
#end
end
def random_password(length)
o = [('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten
password = (0...length).map { o[rand(o.length)] }.join
return password
end
end

36
app/helpers/bbb_helper.rb Normal file
View File

@ -0,0 +1,36 @@
module BbbHelper
def bbb_join_url(meeting_token, meeting_recorded=false, user_fullname='User', user_is_moderator=false)
bbb ||= BigBlueButton::BigBlueButtonApi.new(helpers.bbb_endpoint + "api", bbb_secret, "0.8", true)
if !bbb
return { :returncode => false, :messageKey => "BBBAPICallInvalid", :message => "BBB API call invalid." }
else
meeting_id = (Digest::SHA1.hexdigest("Rails.application.secrets.secret_key_base"+meeting_token)).to_s
#See if the meeting is running
begin
bbb_meeting_info = bbb.get_meeting_info( meeting_id, nil )
rescue BigBlueButton::BigBlueButtonException => exc
logger.info "Message for the log file #{exc.key}: #{exc.message}"
#This means that is not created, so create the meeting
logout_url = "#{request.base_url}/bbb/close" #Closes the window after correct logout
moderator_password = random_password(12)
viewer_password = random_password(12)
meeting_options = {:record => meeting_recorded.to_s, :logoutURL => logout_url, :moderatorPW => moderator_password, :attendeePW => viewer_password }
bbb.create_meeting(meeting_token, meeting_id, meeting_options)
#And then get meeting info
bbb_meeting_info = bbb.get_meeting_info( meeting_id, nil )
end
#Get the join url
if (user_is_moderator)
password = bbb_meeting_info[:moderatorPW]
else
passord = bbb_meeting_info[:attendeePW]
end
join_url = bbb.join_meeting_url(meeting_id, user_fullname, password )
return { :returncode => true, :join_url => join_url, :messageKey => "", :message => "" }
end
end
end