Class: BigbluebuttonServer

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ActiveModel::ForbiddenAttributesProtection
Defined in:
app/models/bigbluebutton_server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#meetingsObject (readonly)

Array of BigbluebuttonMeeting



44
45
46
# File 'app/models/bigbluebutton_server.rb', line 44

def meetings
  @meetings
end

Instance Method Details

#apiObject

Returns the API object (BigBlueButton::BigBlueButtonAPI defined in bigbluebutton-api-ruby) associated with this server.



51
52
53
54
55
56
57
# File 'app/models/bigbluebutton_server.rb', line 51

def api
  if @api.nil?
    @api = BigBlueButton::BigBlueButtonApi.new(self.url, self.salt,
                                               self.version.to_s, false)
  end
  @api
end

#fetch_meetingsObject

Fetches the meetings currently created in the server (running or not).

Using the response, updates meetings with a list of BigbluebuttonMeeting objects.

Triggers API call: getMeetings.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'app/models/bigbluebutton_server.rb', line 65

def fetch_meetings
  response = self.api.get_meetings

  # updates the information in the rooms that are currently in BBB
  @meetings = []
  response[:meetings].each do |attr|
    room = BigbluebuttonRoom.find_by_server_id_and_meetingid(self.id, attr[:meetingID])
    # TODO: there might be more attributes returned by the API, review them all
    if room.nil?
      room = BigbluebuttonRoom.new(:server => self, :meetingid => attr[:meetingID],
                                   :name => attr[:meetingID], :attendee_password => attr[:attendeePW],
                                   :moderator_password => attr[:moderatorPW], :external => true, :private => true)
    else
      room.update_attributes(:attendee_password => attr[:attendeePW],
                             :moderator_password => attr[:moderatorPW])
    end
    room.running = attr[:running]
    room.update_current_meeting

    @meetings << room
  end
end

#fetch_recordings(filter = {}) ⇒ Object

Sends a call to the BBB server to get the list of recordings and updates the database with these recordings.

filter

filters to be used, uses the same format accepted by BigBlueButtonApi::get_recordings. Can filter by meetingID and/or metadata values.

Triggers API call: getRecordings.



122
123
124
125
126
127
128
# File 'app/models/bigbluebutton_server.rb', line 122

def fetch_recordings(filter={})
  logger.info "Fetching recordings for the server #{self.inspect} with filter: #{filter.inspect}"
  recordings = self.api.get_recordings(filter)
  if recordings and recordings[:recordings]
    BigbluebuttonRecording.sync(self, recordings[:recordings])
  end
end

#send_delete_recordings(ids) ⇒ Object

Sends a call to the BBB server to delete a recording or a set or recordings.

ids

IDs of the recordings that will be affected. Accepts the same format accepted by BigBlueButtonApi::delete_recordings

Triggers API call: deleteRecordings.



111
112
113
# File 'app/models/bigbluebutton_server.rb', line 111

def send_delete_recordings(ids)
  self.api.delete_recordings(ids)
end

#send_publish_recordings(ids, publish) ⇒ Object

Sends a call to the BBB server to publish or unpublish a recording or a set of recordings.

ids

IDs of the recordings that will be affected. Accepts the same format accepted by BigBlueButtonApi::publish_recordings

publish

Publish or unpublish the recordings?

Triggers API call: publishRecordings.



95
96
97
98
99
100
101
102
103
104
# File 'app/models/bigbluebutton_server.rb', line 95

def send_publish_recordings(ids, publish)
  self.api.publish_recordings(ids, publish)

  # Update #published in all recordings
  ids = ids.split(",") if ids.instance_of?(String) # "id1,id2" to ["id1", "id2"]
  ids.each do |id|
    recording = BigbluebuttonRecording.find_by_recordid(id.strip)
    recording.update_attributes(:published => publish) unless recording.nil?
  end
end

#to_paramObject



130
131
132
# File 'app/models/bigbluebutton_server.rb', line 130

def to_param
  self.param
end