bigbluebutton_rails 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. data/.gitignore +6 -0
  2. data/.rspec +2 -0
  3. data/CHANGELOG.rdoc +6 -0
  4. data/Gemfile +4 -0
  5. data/Gemfile.lock +111 -0
  6. data/README.rdoc +147 -0
  7. data/Rakefile +37 -0
  8. data/app/controllers/bigbluebutton/rooms_controller.rb +193 -0
  9. data/app/controllers/bigbluebutton/servers_controller.rb +56 -0
  10. data/app/models/bigbluebutton_room.rb +16 -0
  11. data/app/models/bigbluebutton_server.rb +25 -0
  12. data/app/views/bigbluebutton/rooms/_form.html.erb +41 -0
  13. data/app/views/bigbluebutton/rooms/edit.html.erb +6 -0
  14. data/app/views/bigbluebutton/rooms/index.html.erb +34 -0
  15. data/app/views/bigbluebutton/rooms/join_wait.html.erb +27 -0
  16. data/app/views/bigbluebutton/rooms/new.html.erb +5 -0
  17. data/app/views/bigbluebutton/rooms/show.html.erb +35 -0
  18. data/app/views/bigbluebutton/servers/_form.html.erb +32 -0
  19. data/app/views/bigbluebutton/servers/edit.html.erb +6 -0
  20. data/app/views/bigbluebutton/servers/index.html.erb +27 -0
  21. data/app/views/bigbluebutton/servers/new.html.erb +5 -0
  22. data/app/views/bigbluebutton/servers/show.html.erb +31 -0
  23. data/bigbluebutton_rails.gemspec +27 -0
  24. data/config/locales/en.yml +18 -0
  25. data/config/routes.rb +2 -0
  26. data/lib/bigbluebutton_rails.rb +7 -0
  27. data/lib/bigbluebutton_rails/controller_methods.rb +52 -0
  28. data/lib/bigbluebutton_rails/rails.rb +11 -0
  29. data/lib/bigbluebutton_rails/rails/routes.rb +102 -0
  30. data/lib/bigbluebutton_rails/version.rb +3 -0
  31. data/lib/generators/bigbluebutton_rails/install_generator.rb +25 -0
  32. data/lib/generators/bigbluebutton_rails/public_generator.rb +17 -0
  33. data/lib/generators/bigbluebutton_rails/templates/migration.rb +31 -0
  34. data/lib/generators/bigbluebutton_rails/templates/public/images/loading.gif +0 -0
  35. data/lib/generators/bigbluebutton_rails/templates/public/javascripts/heartbeat.js +54 -0
  36. data/lib/generators/bigbluebutton_rails/templates/public/javascripts/jquery.min.js +16 -0
  37. data/lib/generators/bigbluebutton_rails/views_generator.rb +18 -0
  38. data/spec/bigbluebutton_rails_spec.rb +11 -0
  39. data/spec/controllers/bigbluebutton/rooms_controller_spec.rb +404 -0
  40. data/spec/controllers/bigbluebutton/servers_controller_spec.rb +78 -0
  41. data/spec/factories/bigbluebutton_room.rb +8 -0
  42. data/spec/factories/bigbluebutton_server.rb +6 -0
  43. data/spec/generators/install_generator_spec.rb +23 -0
  44. data/spec/generators/public_generator_spec.rb +32 -0
  45. data/spec/generators/views_generator_spec.rb +52 -0
  46. data/spec/models/bigbluebutton_room_spec.rb +48 -0
  47. data/spec/models/bigbluebutton_server_spec.rb +83 -0
  48. data/spec/rails_app/.gitignore +3 -0
  49. data/spec/rails_app/Rakefile +7 -0
  50. data/spec/rails_app/app/controllers/application_controller.rb +16 -0
  51. data/spec/rails_app/app/controllers/space_controller.rb +8 -0
  52. data/spec/rails_app/app/controllers/user_controller.rb +8 -0
  53. data/spec/rails_app/app/helpers/application_helper.rb +2 -0
  54. data/spec/rails_app/app/views/layouts/application.html.erb +14 -0
  55. data/spec/rails_app/app/views/space/index.html.erb +2 -0
  56. data/spec/rails_app/app/views/space/show.html.erb +2 -0
  57. data/spec/rails_app/app/views/user/index.html.erb +2 -0
  58. data/spec/rails_app/app/views/user/show.html.erb +2 -0
  59. data/spec/rails_app/config.ru +4 -0
  60. data/spec/rails_app/config/application.rb +45 -0
  61. data/spec/rails_app/config/boot.rb +10 -0
  62. data/spec/rails_app/config/database.yml +22 -0
  63. data/spec/rails_app/config/environment.rb +5 -0
  64. data/spec/rails_app/config/environments/development.rb +26 -0
  65. data/spec/rails_app/config/environments/production.rb +49 -0
  66. data/spec/rails_app/config/environments/test.rb +35 -0
  67. data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  68. data/spec/rails_app/config/initializers/inflections.rb +10 -0
  69. data/spec/rails_app/config/initializers/mime_types.rb +5 -0
  70. data/spec/rails_app/config/initializers/secret_token.rb +7 -0
  71. data/spec/rails_app/config/initializers/session_store.rb +8 -0
  72. data/spec/rails_app/config/locales/en.yml +5 -0
  73. data/spec/rails_app/config/routes.rb +14 -0
  74. data/spec/rails_app/db/seeds.rb +7 -0
  75. data/spec/rails_app/doc/README_FOR_APP +2 -0
  76. data/spec/rails_app/public/404.html +26 -0
  77. data/spec/rails_app/public/422.html +26 -0
  78. data/spec/rails_app/public/500.html +26 -0
  79. data/spec/rails_app/public/favicon.ico +0 -0
  80. data/spec/rails_app/public/images/rails.png +0 -0
  81. data/spec/rails_app/public/index.html +239 -0
  82. data/spec/rails_app/public/javascripts/application.js +2 -0
  83. data/spec/rails_app/public/javascripts/controls.js +965 -0
  84. data/spec/rails_app/public/javascripts/dragdrop.js +974 -0
  85. data/spec/rails_app/public/javascripts/effects.js +1123 -0
  86. data/spec/rails_app/public/javascripts/prototype.js +6001 -0
  87. data/spec/rails_app/public/javascripts/rails.js +191 -0
  88. data/spec/rails_app/public/robots.txt +5 -0
  89. data/spec/rails_app/public/stylesheets/.gitkeep +0 -0
  90. data/spec/rails_app/public/stylesheets/scaffold.css +56 -0
  91. data/spec/rails_app/script/rails +6 -0
  92. data/spec/rails_app/vendor/plugins/.gitkeep +0 -0
  93. data/spec/routing/bigbluebutton/rooms_routing_spec.rb +89 -0
  94. data/spec/routing/bigbluebutton/servers_routing_spec.rb +38 -0
  95. data/spec/spec_helper.rb +37 -0
  96. data/spec/support/matchers/have_same_attributes_as.rb +10 -0
  97. metadata +234 -0
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *~
2
+ rdoc/*
3
+ pkg
4
+ *.sqlite3
5
+ log
6
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format progress
2
+ --color
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,6 @@
1
+ == 0.1.0
2
+
3
+ * First version
4
+ * DB models for BigBlueButton servers and rooms
5
+ * Controller to access servers and rooms
6
+ * rooms_controller interacts with a BBB server using bigbluebutton-api-ruby
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
4
+
data/Gemfile.lock ADDED
@@ -0,0 +1,111 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ bigbluebutton_rails (0.0.1)
5
+ bigbluebutton-api-ruby (~> 0.0.8)
6
+ rails (~> 3.0.3)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ abstract (1.0.0)
12
+ actionmailer (3.0.5)
13
+ actionpack (= 3.0.5)
14
+ mail (~> 2.2.15)
15
+ actionpack (3.0.5)
16
+ activemodel (= 3.0.5)
17
+ activesupport (= 3.0.5)
18
+ builder (~> 2.1.2)
19
+ erubis (~> 2.6.6)
20
+ i18n (~> 0.4)
21
+ rack (~> 1.2.1)
22
+ rack-mount (~> 0.6.13)
23
+ rack-test (~> 0.5.7)
24
+ tzinfo (~> 0.3.23)
25
+ activemodel (3.0.5)
26
+ activesupport (= 3.0.5)
27
+ builder (~> 2.1.2)
28
+ i18n (~> 0.4)
29
+ activerecord (3.0.5)
30
+ activemodel (= 3.0.5)
31
+ activesupport (= 3.0.5)
32
+ arel (~> 2.0.2)
33
+ tzinfo (~> 0.3.23)
34
+ activeresource (3.0.5)
35
+ activemodel (= 3.0.5)
36
+ activesupport (= 3.0.5)
37
+ activesupport (3.0.5)
38
+ arel (2.0.9)
39
+ bigbluebutton-api-ruby (0.0.8)
40
+ nokogiri (~> 1.4.0)
41
+ builder (2.1.2)
42
+ diff-lcs (1.1.2)
43
+ erubis (2.6.6)
44
+ abstract (>= 1.0.0)
45
+ factory_girl (1.3.3)
46
+ forgery (0.3.7)
47
+ nokogiri (~> 1.4)
48
+ generator_spec (0.8.2)
49
+ rails (~> 3.0)
50
+ rspec-rails
51
+ i18n (0.5.0)
52
+ mail (2.2.15)
53
+ activesupport (>= 2.3.6)
54
+ i18n (>= 0.4.0)
55
+ mime-types (~> 1.16)
56
+ treetop (~> 1.4.8)
57
+ mime-types (1.16)
58
+ nokogiri (1.4.4)
59
+ polyglot (0.3.1)
60
+ rack (1.2.2)
61
+ rack-mount (0.6.14)
62
+ rack (>= 1.0.0)
63
+ rack-test (0.5.7)
64
+ rack (>= 1.0)
65
+ rails (3.0.5)
66
+ actionmailer (= 3.0.5)
67
+ actionpack (= 3.0.5)
68
+ activerecord (= 3.0.5)
69
+ activeresource (= 3.0.5)
70
+ activesupport (= 3.0.5)
71
+ bundler (~> 1.0)
72
+ railties (= 3.0.5)
73
+ railties (3.0.5)
74
+ actionpack (= 3.0.5)
75
+ activesupport (= 3.0.5)
76
+ rake (>= 0.8.7)
77
+ thor (~> 0.14.4)
78
+ rake (0.8.7)
79
+ rspec (2.5.0)
80
+ rspec-core (~> 2.5.0)
81
+ rspec-expectations (~> 2.5.0)
82
+ rspec-mocks (~> 2.5.0)
83
+ rspec-core (2.5.1)
84
+ rspec-expectations (2.5.0)
85
+ diff-lcs (~> 1.1.2)
86
+ rspec-mocks (2.5.0)
87
+ rspec-rails (2.5.0)
88
+ actionpack (~> 3.0)
89
+ activesupport (~> 3.0)
90
+ railties (~> 3.0)
91
+ rspec (~> 2.5.0)
92
+ shoulda-matchers (1.0.0.beta2)
93
+ sqlite3 (1.3.3)
94
+ sqlite3-ruby (1.3.3)
95
+ sqlite3 (>= 1.3.3)
96
+ thor (0.14.6)
97
+ treetop (1.4.9)
98
+ polyglot (>= 0.3.1)
99
+ tzinfo (0.3.26)
100
+
101
+ PLATFORMS
102
+ ruby
103
+
104
+ DEPENDENCIES
105
+ bigbluebutton_rails!
106
+ factory_girl (~> 1.3.2)
107
+ forgery (~> 0.3.7)
108
+ generator_spec (~> 0.8.2)
109
+ rspec-rails (~> 2.5.0)
110
+ shoulda-matchers (~> 1.0.0.beta)
111
+ sqlite3-ruby (~> 1.3.3)
data/README.rdoc ADDED
@@ -0,0 +1,147 @@
1
+ = BigBlueButton on Rails
2
+
3
+ BigBlueButton (http://bigbluebutton.org) integration for Ruby on Rails 3.
4
+
5
+ Features:
6
+ * Allows multiple servers and multiple conference rooms
7
+ * Full API access using bigbluebutton-api-ruby (https://github.com/mconf/bigbluebutton-api-ruby)
8
+ * Easy way to join conferences: simply create a room and call the "join" action
9
+ * Easy integration with authentication and authorization mechanisms, such as Devise and CanCan
10
+
11
+ Future:
12
+ * Friendly URLs (e.g. http://somewhere.com/my-server/my-room)
13
+ * Random meeting IDs to avoid problems with end_meeting and timeouts
14
+ * Server administration (modify config.xml, use bbb-conf, etc.)
15
+
16
+ For more future features and issues check http://code.google.com/p/mconf/issues/list?can=2&q=label%3AComponent%20label%3ABigBlueButtonRails
17
+
18
+ == Installation
19
+
20
+ You can install the latest version of bigbluebutton_rails using RubyGems:
21
+
22
+ gem install bigbluebutton_rails
23
+
24
+ Or simply add the following line in your Gemfile:
25
+
26
+ gem "bigbluebutton_rails"
27
+
28
+ After installing, you need to run the generator:
29
+
30
+ rails generate bigbluebutton_rails:install
31
+
32
+ This generator will create a migration file and a locale file in your application directories.
33
+ Take a look at the migration to see how the models used by bigbluebutton_rails look like.
34
+
35
+ All models, controllers and views used are embedded in the gem, but you can replace or extend them if you need to.
36
+ There is one generator to help you with that:
37
+
38
+ rails generate bigbluebutton_rails:views
39
+
40
+ It copies all bigbluebutton_rails views into your application, so you can customize them as you wish.
41
+
42
+ There is yet another generator that copies the public files (javascripts, images and stylesheets) used by bigbluebutton_rails:
43
+
44
+ rails generate bigbluebutton_rails:public
45
+
46
+ For more information see the section Dependencies below.
47
+
48
+ === Routes
49
+
50
+ The routes to bigbluebutton_rails can be generated with the helper "bigbluebutton_routes". See the example below:
51
+
52
+ bigbluebutton_routes :default
53
+
54
+ resources :users do
55
+ bigbluebutton_routes :room_matchers
56
+ resources :spaces do
57
+ bigbluebutton_routes :room_matchers
58
+ end
59
+ end
60
+
61
+ The first line generates the default routes. You need to call it at least once to generate the following routes:
62
+
63
+ bigbluebutton_routes :default
64
+
65
+ To have your rooms beloging to a model other than servers, use the room_matchers:
66
+
67
+ bigbluebutton_routes :room_matchers
68
+
69
+ It creates routes to the actions "show", "running", "end", and "join".
70
+ So you can allow access to webconference rooms using URLs such as:
71
+
72
+ http://myserver.com/user-10/room-5/join
73
+ http://myserver.com/zaphod/public-room/join
74
+
75
+ PS: bigbluebutton_rails does not allows the room access using IDs such as "room-5" or "public-room" yet, but soon you it will.
76
+
77
+ === User authorization, permissions and assumptions
78
+
79
+ There are some basic assumptions made by bigbluebutton_rails:
80
+
81
+ * You have a method called "current_user" that returns the current user;
82
+ * The current_user has an attribute or method called "name" that returns his/her fullname.
83
+
84
+ If you don't, you can change this behaviour easily, keep reading.
85
+
86
+ bigbluebutton_rails uses the methods "bigbluebutton_user" and "bigbluebutton_role(room)" to get the current user and to get the permission that the current
87
+ user has in the "room", respectively.
88
+
89
+ These methods are defined in "lib/bigbluebutton_rails/controller_methods.rb" and you can reimplement them in your application_controller to change their behaviour.
90
+
91
+
92
+ ==== Integration with Devise
93
+
94
+ To be written...
95
+
96
+ ==== Integration with CanCan
97
+
98
+ To be written...
99
+
100
+ === Dependencies
101
+
102
+ For gem dependencies check the gemspec file.
103
+
104
+ Files:
105
+
106
+ * Javascripts:
107
+ * JQuery (jquery.min.js). See http://jquery.com
108
+ * JQuery Heartbeat plugin (heartbeat.js). See http://plugins.jquery.com/project/Heartbeat
109
+ * Images:
110
+ * loading.gif
111
+
112
+ All these files are used by views/bigbluebutton/rooms/join_wait and can be generated with:
113
+
114
+ rails generate bigbluebutton_rails:public
115
+
116
+ == How it works
117
+
118
+ bigbluebutton_rails has two entities: servers and rooms. Servers can have multiple rooms, that belong to a server and can also belong to any other model.
119
+ You can make a room belong to a user, for example.
120
+
121
+ Every server has an associated API object (using the gem bigbluebutton-api-ruby) used to access BigBlueButton.
122
+ The server now has basically the RESTful actions defined in Rails.
123
+
124
+ The rooms also have the RESTful actions, plus specific actions to "join", "end", and check if a meeting is being held currently in the room ("running").
125
+ All actions are pretty simple. "running" returns a json indicating if the conference is running or not and "end" ends the meeting.
126
+ The most elaborated action is "join", that does the following:
127
+
128
+ * If the user is a moderator:
129
+ * If the rooms is not created yet, creates it.
130
+ * Redirects to the url to join as a moderator.
131
+ * If the user is a normal attendee:
132
+ * If the rooms is running, redirects to the url to join as an attendee.
133
+ * Otherwise, redirects to join_wait, to wait for a moderator before joining the conference.
134
+
135
+ == Development
136
+
137
+ Install the dependencies:
138
+
139
+ bundle install
140
+
141
+ Prepare the rails_app used for tests:
142
+
143
+ rake setup:rails_app
144
+
145
+ Run the tests:
146
+
147
+ rake spec
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'rake/rdoctask'
4
+ require 'rspec/core/rake_task'
5
+ require 'rake/gempackagetask'
6
+
7
+ desc 'Default: run tests.'
8
+ task :default => :spec
9
+
10
+ RSpec::Core::RakeTask.new(:spec)
11
+
12
+ desc 'Generate documentation.'
13
+ Rake::RDocTask.new(:rdoc) do |rdoc|
14
+ rdoc.rdoc_dir = 'rdoc'
15
+ rdoc.title = 'BigBlueButton on Rails'
16
+ rdoc.rdoc_files.include('README.rdoc')
17
+ rdoc.rdoc_files.include('CHANGELOG.rdoc')
18
+ rdoc.rdoc_files.include('lib/**/*.rb')
19
+ end
20
+
21
+ eval("$specification = begin; #{ IO.read('bigbluebutton_rails.gemspec')}; end")
22
+ Rake::GemPackageTask.new $specification do |pkg|
23
+ pkg.need_tar = true
24
+ pkg.need_zip = true
25
+ end
26
+
27
+ desc 'Setup RailsApp used in tests.'
28
+ namespace "setup" do
29
+ task :rails_app do |app|
30
+ cd 'spec/rails_app/'
31
+ sh "rake db:drop ENV=test"
32
+ sh "rails destroy bigbluebutton_rails:install"
33
+ sh "rails generate bigbluebutton_rails:install"
34
+ sh "rake db:migrate ENV=test"
35
+ sh "rake db:test:prepare"
36
+ end
37
+ end
@@ -0,0 +1,193 @@
1
+ require 'bigbluebutton-api'
2
+
3
+ class Bigbluebutton::RoomsController < ApplicationController
4
+
5
+ # TODO create filter find_room
6
+
7
+ before_filter :find_server
8
+ respond_to :html, :except => :running
9
+ respond_to :json, :only => :running
10
+
11
+ def index
12
+ # TODO restrict to rooms belonging to the selected server
13
+ respond_with(@rooms = BigbluebuttonRoom.all)
14
+ end
15
+
16
+ def show
17
+ respond_with(@room = BigbluebuttonRoom.find(params[:id]))
18
+ end
19
+
20
+ def new
21
+ respond_with(@room = BigbluebuttonRoom.new)
22
+ end
23
+
24
+ def edit
25
+ respond_with(@room = BigbluebuttonRoom.find(params[:id]))
26
+ end
27
+
28
+ def create
29
+ @room = BigbluebuttonRoom.new(params[:bigbluebutton_room])
30
+ @room.server = @server
31
+
32
+ # TODO Generate a random meeting_id everytime a room is created
33
+ if !params[:bigbluebutton_room].has_key?(:meeting_id) or
34
+ params[:bigbluebutton_room][:meeting_id].blank?
35
+ @room.meeting_id = @room.name
36
+ end
37
+
38
+ respond_with @room do |format|
39
+ if @room.save
40
+ format.html {
41
+ message = t('bigbluebutton_rails.rooms.notice.create.success')
42
+ redirect_to(bigbluebutton_server_room_path(@server, @room), :notice => message)
43
+ }
44
+ else
45
+ format.html { render :action => "new" }
46
+ end
47
+ end
48
+ end
49
+
50
+ def update
51
+ @room = BigbluebuttonRoom.find(params[:id])
52
+
53
+ if !params[:bigbluebutton_room].has_key?(:meeting_id) or
54
+ params[:bigbluebutton_room][:meeting_id].blank?
55
+ params[:bigbluebutton_room][:meeting_id] = params[:bigbluebutton_room][:name]
56
+ end
57
+
58
+ respond_with @room do |format|
59
+ if @room.update_attributes(params[:bigbluebutton_room])
60
+ format.html {
61
+ message = t('bigbluebutton_rails.rooms.notice.update.success')
62
+ redirect_to(bigbluebutton_server_room_path(@server, @room), :notice => message)
63
+ }
64
+ else
65
+ format.html { render :action => "edit" }
66
+ end
67
+ end
68
+ end
69
+
70
+ def destroy
71
+ @room = BigbluebuttonRoom.find(params[:id])
72
+
73
+ # TODO Destroy room even if end_meeting failed?
74
+
75
+ begin
76
+ bbb_end_meeting if bbb_is_meeting_running?
77
+ rescue BigBlueButton::BigBlueButtonException => e
78
+ flash[:error] = e.to_s
79
+ # TODO Better error message: "Room destroyed in DB, but not in BBB..."
80
+ end
81
+
82
+ @room.destroy
83
+ redirect_to(bigbluebutton_server_rooms_url)
84
+ end
85
+
86
+ def join
87
+ @room = BigbluebuttonRoom.find(params[:id])
88
+ role = bigbluebutton_role(@room)
89
+
90
+ begin
91
+
92
+ # if the current user is a moderator, create the room (if needed)
93
+ # and join it
94
+ if role == :moderator
95
+ bbb_create_room unless bbb_is_meeting_running?
96
+ join_url = bbb_join_url(bigbluebutton_user.name, role)
97
+ redirect_to(join_url)
98
+
99
+ # normal user only joins if the conference is running
100
+ # if it's not, wait for a moderator to create the conference
101
+ else
102
+ if bbb_is_meeting_running?
103
+ join_url = bbb_join_url(bigbluebutton_user.name, role)
104
+ redirect_to(join_url)
105
+ else
106
+ render :action => :join_wait
107
+ end
108
+ end
109
+
110
+ rescue BigBlueButton::BigBlueButtonException => e
111
+ flash[:error] = e.to_s
112
+ redirect_to request.referer
113
+ end
114
+
115
+ end
116
+
117
+ def join_wait
118
+ end
119
+
120
+ def running
121
+ @room = BigbluebuttonRoom.find(params[:id])
122
+
123
+ begin
124
+ run = bbb_is_meeting_running?
125
+ rescue BigBlueButton::BigBlueButtonException => e
126
+ flash[:error] = e.to_s
127
+ render :json => { running: "false", error: "#{e.to_s}" }
128
+ #redirect_to request.referer
129
+ else
130
+ render :json => { running: "#{run}" }
131
+ end
132
+
133
+ end
134
+
135
+ def end
136
+ @room = BigbluebuttonRoom.find(params[:id])
137
+
138
+ begin
139
+ if bbb_is_meeting_running?
140
+ bbb_end_meeting
141
+ message = t('bigbluebutton_rails.rooms.notice.end.success')
142
+ else
143
+ message = t('bigbluebutton_rails.rooms.notice.end.not_running')
144
+ end
145
+ rescue BigBlueButton::BigBlueButtonException => e
146
+ flash[:error] = e.to_s
147
+ redirect_to request.referer
148
+ else
149
+ redirect_to(bigbluebutton_server_room_path(@server, @room), :notice => message)
150
+ end
151
+
152
+ end
153
+
154
+ protected
155
+
156
+ def find_server
157
+ if params.has_key?(:server_id)
158
+ @server = BigbluebuttonServer.find(params[:server_id])
159
+ else
160
+ @server = BigbluebuttonServer.first
161
+ end
162
+ end
163
+
164
+
165
+ #
166
+ # Functions that directly call the BBB API. All prefixed with bbb_
167
+ #
168
+
169
+ def bbb_is_meeting_running?
170
+ @server.api.is_meeting_running?(@room.meeting_id)
171
+ end
172
+
173
+ def bbb_end_meeting
174
+ @server.api.end_meeting(@room.meeting_id, @room.moderator_password)
175
+ end
176
+
177
+ def bbb_create_room
178
+ @server.api.create_meeting(@room.name, @room.meeting_id,
179
+ @room.moderator_password, @room.attendee_password,
180
+ @room.welcome_msg)
181
+ end
182
+
183
+ def bbb_join_url(username, role)
184
+ if role == :moderator
185
+ @server.api.join_meeting_url(@room.meeting_id, username,
186
+ @room.moderator_password)
187
+ else
188
+ @server.api.join_meeting_url(@room.meeting_id, username,
189
+ @room.attendee_password)
190
+ end
191
+ end
192
+
193
+ end