bigbluebutton 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/LICENSE +3 -0
  2. data/README +23 -0
  3. data/Rakefile +53 -0
  4. data/lib/bigbluebutton.rb +140 -0
  5. metadata +66 -0
data/LICENSE ADDED
@@ -0,0 +1,3 @@
1
+ == bigbluebutton
2
+
3
+ Put appropriate LICENSE for your project here.
data/README ADDED
@@ -0,0 +1,23 @@
1
+ = Project: bigbluebutton
2
+
3
+ == Goal
4
+
5
+ Provide access to the BigBlueButton web conferencing API.
6
+
7
+ == Releases
8
+
9
+ === Version 0.0.1
10
+ This is the first version of this gem. It provides an implementation of the
11
+ 0.64 bbb API, with the following exceptions:
12
+
13
+ - Does not implement meeting token, and instead relies on meeting id as the
14
+ unique identifier for a meeting.
15
+ - Documentation suggests there is way to call join_meeting as API call
16
+ (instead of browser URL). This call currently does not work as documented.
17
+
18
+ == Contact
19
+
20
+ Author:: Joe Kinsella
21
+ Email:: joe.kinsella@gmail.com
22
+ Home Page:: http://www.brownbaglunch.com/bigbluebutton
23
+ License:: Distributes under same terms as Ruby
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ #
2
+ # To change this template, choose Tools | Templates
3
+ # and open the template in the editor.
4
+
5
+
6
+ require 'rubygems'
7
+ require 'rake'
8
+ require 'rake/clean'
9
+ require 'rake/gempackagetask'
10
+ require 'rake/rdoctask'
11
+ require 'rake/testtask'
12
+
13
+ spec = Gem::Specification.new do |s|
14
+ s.name = 'bigbluebutton'
15
+ s.version = '0.0.1'
16
+ s.has_rdoc = true
17
+ s.extra_rdoc_files = ['README', 'LICENSE']
18
+ s.summary = 'Provides an interface to the BigBlueButton web meeting API (http://code.google.com/p/bigbluebutton/)'
19
+ s.description = s.summary
20
+ s.author = 'Joe Kinsella'
21
+ s.email = 'joe.kinsella@gmail.com'
22
+ s.homepage = "http://www.brownbaglunch.com/bigbluebutton"
23
+ # s.executables = ['your_executable_here']
24
+ s.files = %w(LICENSE README Rakefile) + Dir.glob("{bin,lib,spec}/**/*")
25
+ s.require_path = "lib"
26
+ s.bindir = "bin"
27
+ end
28
+
29
+ Rake::GemPackageTask.new(spec) do |p|
30
+ p.gem_spec = spec
31
+ p.need_tar = true
32
+ p.need_zip = true
33
+ end
34
+
35
+ Rake::RDocTask.new do |rdoc|
36
+ files =['README', 'LICENSE', 'lib/**/*.rb']
37
+ rdoc.rdoc_files.add(files)
38
+ rdoc.main = "README" # page to start on
39
+ rdoc.title = "bigbluebutton Docs"
40
+ rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
41
+ rdoc.options << '--line-numbers'
42
+ end
43
+
44
+ Rake::TestTask.new do |t|
45
+ t.test_files = FileList['test/**/*.rb']
46
+ end
47
+
48
+ desc 'Test the gem.'
49
+ Rake::TestTask.new(:test) do |t|
50
+ t.pattern = 'test/**/*_test.rb'
51
+ t.verbose = true
52
+ t.libs << 'test'
53
+ end
@@ -0,0 +1,140 @@
1
+ require 'net/http'
2
+ require 'cgi'
3
+ require 'rexml/document'
4
+ require 'digest/sha1'
5
+
6
+ module BigBlueButton
7
+
8
+ # This class provides access to the BigBlueButton API. BigBlueButton
9
+ # is an open source project that provides web conferencing for distance
10
+ # education (http://code.google.com/p/bigbluebutton/wiki/API). This API
11
+ # was developed to the 0.64 version of bbb.
12
+ #
13
+ # Sample usage of the API is as follows:
14
+ # 1) Create a meeting with the create_meeting call
15
+ # 2) Direct a user to either moderator_url or attendee_url
16
+ # 3) To force meeting to end, call end_meeting
17
+ #
18
+ # Author:: Joe Kinsella (mailto:joe.kinsella@gmail.com)
19
+ # Copyright:: Copyright (c) 2010 Joe Kinsella
20
+ # License:: Distributes under same terms as Ruby
21
+ class BigBlueButtonApi
22
+
23
+ # Initializes an instance
24
+ # base_url:: URL to a BigBlueButton server (defaults to bbb development server)
25
+ # salt:: Secret salt for this server (defaults to bbb development server)"http://devbuild.bigbluebu
26
+ def initialize(base_url = 'http://devbuild.bigbluebutton.org/bigbluebutton/api', salt = '639259d4-9dd8-4b25-bf01-95f9567eaf4b', debug=false)
27
+ @session = {}
28
+ @base_url = base_url
29
+ @salt = salt
30
+ @debug = debug
31
+ end
32
+
33
+ # Returns url to login as moderator
34
+ # meeting_id:: Unique identifier for the meeting
35
+ # user_name:: Name of the user
36
+ # password:: Moderator password for this meeting
37
+ def moderator_url(meeting_id, user_name, password)
38
+ attendee_url(meeting_id, user_name, password)
39
+ end
40
+
41
+ # Returns url to login as attendee
42
+ # meeting_id:: Unique identifier for the meeting
43
+ # user_name:: Name of the user
44
+ # password:: Attendee password for this meeting
45
+ def attendee_url(meeting_id, user_name, attendee_password)
46
+ get_url(:join, {:meetingID=>meeting_id,:password=>attendee_password, :fullName=>user_name})
47
+ end
48
+
49
+ # Creates a new meeting. Throws BigBlueButtonException on failure.
50
+ # meeting_id:: Unique identifier for the meeting
51
+ # meeting_name:: Name for the meeting
52
+ # moderator_password:: Moderator password
53
+ # attendee_password:: Attendee password
54
+ # welcome_message:: Welcome message to display in chat window
55
+ # dialin_number:: Dial in number for conference
56
+ # logout_url:: URL to return user to after exiting meeting
57
+ def create_meeting(meeting_id, meeting_name, moderator_password, attendee_password,
58
+ welcome_message = nil, dialin_number = nil, logout_url = nil, max_participants = nil)
59
+
60
+ send_api_request(:create, {:name=>meeting_name, :meetingID=>meeting_id,
61
+ :moderatorPW=>moderator_password, :attendeePW=>attendee_password,
62
+ :welcome=>welcome_message, :dialNumber=>dialin_number,
63
+ :logoutURL=>logout_url, :maxParticpants=>max_participants} )
64
+ end
65
+
66
+ # Ends an existing meeting. Throws BigBlueButtonException on failure.
67
+ # meeting_id:: Unique identifier for the meeting
68
+ # moderator_password:: Moderator password
69
+ def end_meeting(meeting_id, moderator_password)
70
+ send_api_request(:end, {:meetingID=>meeting_id,:password=>moderator_password} )
71
+ end
72
+
73
+ # Returns true or false as to whether meeting is open. A meeting is
74
+ # only open after at least one participant has joined.
75
+ # meeting_id:: Unique identifier for the meeting
76
+ def is_meeting_running(meeting_id)
77
+ doc = send_api_request(:isMeetingRunning, {:meetingID=>meeting_id} )
78
+ running = doc.root.get_text('/response/running').to_s
79
+ running == "true"
80
+ end
81
+
82
+ # Warning: As of this version of the gem, this bbb call does not work
83
+ # (instead of returning XML response, joins meeting).
84
+ #
85
+ # Joins a user into the meeting using an API call, instead of
86
+ # directing the user's browser to moderator_url or attendee_url
87
+ # (note: this will still be required however to actually use bbb).
88
+ # Returns the URL a user can use to enter this meeting.
89
+ # meeting_id:: Unique identifier for the meeting
90
+ # user_name:: Name of the user
91
+ # password:: Moderator or attendee password for this meeting
92
+ def join_meeting(meeting_id, user_name, password)
93
+ send_api_request(:join, {:meetingID=>meeting_id, :password=>password,
94
+ :fullName=>user_name, :redirectImmediately=>0} )
95
+ doc.root.get_text('/response/entryURL').to_s
96
+ end
97
+
98
+ # Returns a REXML::Document object containing the meeting information.
99
+ # See the API documentation for details on the return XML
100
+ # (http://code.google.com/p/bigbluebutton/wiki/API).
101
+ #
102
+ # meeting_id:: Unique identifier for the meeting
103
+ # password:: Moderator password for this meeting
104
+ def get_meeting_info(meeting_id, password)
105
+ send_api_request(:getMeetingInfo, {:meetingID=>meeting_id, :password=>password} )
106
+ end
107
+
108
+ protected
109
+
110
+ def get_url(method, data)
111
+ base_url = "#{@base_url}/#{method}?"
112
+ params = ""
113
+ data.each {|key, value|
114
+ params += key.to_s + "=" + CGI.escape(value.to_s) + "&" unless key.nil? || value.nil?
115
+ }
116
+ checksum = Digest::SHA1.hexdigest(params.chop + @salt)
117
+ "#{base_url}#{params}checksum=#{checksum}"
118
+ end
119
+
120
+ def send_api_request(method, data = {})
121
+ url = get_url(method, data)
122
+ res = Net::HTTP.get_response(URI.parse(url))
123
+ puts "BigBlueButtonAPI: URL=#{url}" if @debug
124
+ puts "BigBlueButtonAPI: URL response=#{res.body}" if @debug
125
+ doc = REXML::Document.new(res.body)
126
+ return_code = doc.root.get_text('/response/returncode')
127
+ message = doc.root.get_text('/response/message')
128
+ unless return_code == "SUCCESS"
129
+ raise BigBlueButtonException.new("BigBlueButton error: #{message}")
130
+ end
131
+ doc
132
+ end
133
+
134
+ end
135
+
136
+ class BigBlueButtonsException < Exception
137
+
138
+ end
139
+
140
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bigbluebutton
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Joe Kinsella
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-03-13 23:00:00 -05:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Provides an interface to the BigBlueButton web meeting API (http://code.google.com/p/bigbluebutton/)
22
+ email: joe.kinsella@gmail.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - README
29
+ - LICENSE
30
+ files:
31
+ - LICENSE
32
+ - README
33
+ - Rakefile
34
+ - lib/bigbluebutton.rb
35
+ has_rdoc: true
36
+ homepage: http://www.brownbaglunch.com/bigbluebutton
37
+ licenses: []
38
+
39
+ post_install_message:
40
+ rdoc_options: []
41
+
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ segments:
49
+ - 0
50
+ version: "0"
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 0
57
+ version: "0"
58
+ requirements: []
59
+
60
+ rubyforge_project:
61
+ rubygems_version: 1.3.6
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: Provides an interface to the BigBlueButton web meeting API (http://code.google.com/p/bigbluebutton/)
65
+ test_files: []
66
+