public function meeting($id = 1, $username = null, $password = null) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query = "SELECT * FROM `#__bbb_meetings` WHERE `id`=" . $id; $db->setQuery($query); $data = $db->loadObject(); if ($data->attendeePW == $password || $data->moderatorPW == $password) { $creationParams = array('meetingId' => $id, 'meetingName' => $data->meetingName, 'attendeePw' => $data->attendeePW, 'moderatorPw' => $data->moderatorPW, 'logoutUrl' => JUri::base(), 'welcomeMsg' => 'Welcome to ' . $data->meetingName, 'dialNumber' => $this->dialNumber, 'voiceBridge' => $data->voiceBridge, 'maxParticipants' => $data->maxParticipants, 'record' => $data->record, 'duration' => $data->duration); $itsAllGood = true; $bbb = new BigBlueButton($this->salt, $this->url); try { $result = $bbb->createMeetingWithXmlResponseArray($creationParams); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; $itsAllGood = false; } if ($itsAllGood == true) { if ($result == null) { $output = "Failed to get any response. Maybe we can't contact the BBB server."; } else { if ($result['returncode'] == 'SUCCESS') { $output = $this->getlink($id, $username, $password); } else { $output = "Meeting creation failed"; } } } } else { $output = "Sorry password don't match"; } return $output; }
function createMeeting($meetingId, $meetingName) { $bbb = new BigBlueButton(); $creationParams = array('meetingId' => $meetingId, 'meetingName' => $meetingName, 'attendeePw' => 'ap', 'moderatorPw' => 'mp', 'welcomeMsg' => 'Seja bem vindo(a) a sala de conferência do Moodle Acessível do grupo WebGD!', 'dialNumber' => '', 'voiceBridge' => '', 'webVoice' => '', 'logoutUrl' => '', 'maxParticipants' => '-1', 'record' => 'false', 'duration' => '0'); // Create the meeting and get back a response: $itsAllGood = true; try { $result = $bbb->createMeetingWithXmlResponseArray($creationParams); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; $itsAllGood = false; } if ($itsAllGood == true) { // If it's all good, then we've interfaced with our BBB php api OK: if ($result == null) { // If we get a null response, then we're not getting any XML back from BBB. echo "Failed to get any response. Maybe we can't contact the BBB server."; } else { // We got an XML response, so let's see what it says: if ($result['returncode'] == 'SUCCESS') { // Then do stuff ... } else { echo "Erro ao criar a webconferência"; } } } }
/* _____ PHP Big Blue Button API Usage ______ * by Peter Mentzer peter@petermentzerdesign.com * Use, modify and distribute however you like. */ // Require the bbb-api file: require_once '../includes/bbb-api.php'; // Instatiate the BBB class: $bbb = new BigBlueButton(); /* ___________ CREATE MEETING w/ OPTIONS ______ */ /* */ $creationParams = array('meetingId' => '12345', 'meetingName' => 'Test Recorded Meeting Name', 'attendeePw' => 'ap', 'moderatorPw' => 'mp', 'welcomeMsg' => '', 'dialNumber' => '', 'voiceBridge' => '', 'webVoice' => '', 'logoutUrl' => '', 'maxParticipants' => '-1', 'record' => 'true', 'duration' => '5'); // Create the meeting and get back a response: $itsAllGood = true; try { $result = $bbb->createMeetingWithXmlResponseArray($creationParams); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; $itsAllGood = false; } if ($itsAllGood == true) { // If it's all good, then we've interfaced with our BBB php api OK: if ($result == null) { // If we get a null response, then we're not getting any XML back from BBB. echo "Failed to get any response. Maybe we can't contact the BBB server."; } else { // We got an XML response, so let's see what it says: print_r($result); if ($result['returncode'] == 'SUCCESS') { // Then do stuff ... echo "<p>Meeting succesfullly created.</p>";
/** * * @global type $course_id * @global type $langBBBCreationRoomError * @global type $langBBBConnectionError * @param type $title * @param type $meeting_id * @param type $mod_pw * @param type $att_pw * @param type $record */ function create_meeting($title, $meeting_id, $mod_pw, $att_pw, $record) { global $course_id, $langBBBCreationRoomError, $langBBBConnectionError; $run_to = -1; $min_users = 10000000; //Get all course participants $users_to_join = Database::get()->querySingle("SELECT COUNT(*) AS count FROM course_user, user WHERE course_user.course_id = ?d AND course_user.user_id = user.id", $course_id)->count; //Algorithm to select BBB server GOES HERE ... if ($record == 'true') { $query = Database::get()->queryArray("SELECT * FROM bbb_servers WHERE enabled='true' AND enable_recordings=?s ORDER BY weight ASC",$record); } else { $query = Database::get()->queryArray("SELECT * FROM bbb_servers WHERE enabled='true' ORDER BY weight ASC"); } if ($query) { foreach ($query as $row) { $max_rooms = $row->max_rooms; $max_users = $row->max_users; // GET connected Participants $connected_users = get_connected_users($row->server_key, $row->api_url, $row->ip); $active_rooms = get_active_rooms($row->server_key,$row->api_url); if ($connected_users<$min_users) { $run_to=$row->id; $min_users = $connected_users; } //cases // max_users = 0 && max_rooms = 0 - UNLIMITED // active_rooms < max_rooms && active_users < max_users // active_rooms < max_rooms && max_users = 0 (UNLIMITED) // active_users < max_users && max_rooms = 0 (UNLIMITED) if (($max_rooms == 0 && $max_users == 0) || (($max_users > ($users_to_join + $connected_users)) && $active_rooms < $max_rooms) || ($active_rooms < $max_rooms && $max_users == 0) || (($max_users > ($users_to_join + $connected_users)) && $max_rooms == 0)) // YOU FOUND THE SERVER { $run_to = $row->id; Database::get()->querySingle("UPDATE bbb_session SET running_at=?s WHERE meeting_id=?s",$row->id, $meeting_id); break; } } } if ($run_to == -1) { // WE SHOULD TAKE ACTION IF NO SERVER AVAILABLE DUE TO CAPACITY PROBLEMS // If no server available we select server with min connected users $temp_conn = 10000000; $query = Database::get()->queryArray("SELECT * FROM bbb_servers WHERE enabled='true' AND enable_recordings=?s ORDER BY weight ASC",$record); if ($query) { foreach ($query as $row) { // GET connected Participants $connected_users = get_connected_users($row->server_key, $row->api_url, $row->ip); if ($connected_users<$temp_conn) { $run_to=$row->id; $temp_conn = $connected_users; } } } Database::get()->querySingle("UPDATE bbb_session SET running_at=?d WHERE meeting_id=?s",$run_to,$meeting_id); } // we find the bbb server that will serve the session $res = Database::get()->querySingle("SELECT * FROM bbb_servers WHERE id=?d", $run_to); if ($res) { $salt = $res->server_key; $bbb_url = $res->api_url; $bbb = new BigBlueButton($salt, $bbb_url); $creationParams = array( 'meetingId' => $meeting_id, // REQUIRED 'meetingName' => $title, // REQUIRED 'attendeePw' => $att_pw, // Match this value in getJoinMeetingURL() to join as attendee. 'moderatorPw' => $mod_pw, // Match this value in getJoinMeetingURL() to join as moderator. 'welcomeMsg' => '', // ''= use default. Change to customize. 'dialNumber' => '', // The main number to call into. Optional. 'voiceBridge' => '', // PIN to join voice. Optional. 'webVoice' => '', // Alphanumeric to join voice. Optional. 'logoutUrl' => '', // Default in bigbluebutton.properties. Optional. 'maxParticipants' => '-1', // Optional. -1 = unlimitted. Not supported in BBB. [number] 'record' => $record, // New. 'true' will tell BBB to record the meeting. 'duration' => '0', // Default = 0 which means no set duration in minutes. [number] //'meta_category' => '', // Use to pass additional info to BBB server. See API docs. ); // Create the meeting and get back a response: $result = $bbb->createMeetingWithXmlResponseArray($creationParams); // If it's all good, then we've interfaced with our BBB php api OK: if ($result == null) { // If we get a null response, then we're not getting any XML back from BBB. echo "<div class='alert-danger'>$langBBBConnectionError</div>"; exit; } else { if ($result['returncode'] == 'SUCCESS') { // Then do stuff ... //echo "<p>Meeting succesfullly created.</p>"; } else { echo "<div class='alert alert-danger'>$langBBBCreationRoomError.</div>"; exit; } } } }
/** * * @global type $course_id * @global type $langBBBCreationRoomError * @global type $langBBBConnectionError * @param type $title * @param type $meeting_id * @param type $mod_pw * @param type $att_pw * @param type $record */ function create_meeting($title, $meeting_id, $mod_pw, $att_pw, $record) { global $course_id, $langBBBCreationRoomError, $langBBBConnectionError; $run_to = -1; $min_users = 10000000; //Get all course participants $users_to_join = Database::get()->querySingle("SELECT COUNT(*) AS count FROM course_user, user\n WHERE course_user.course_id = ?d AND course_user.user_id = user.id", $course_id)->count; //Algorithm to select BBB server GOES HERE ... $query = Database::get()->queryArray("SELECT * FROM bbb_servers WHERE enabled='true' AND enable_recordings=?s ORDER BY weight ASC", $record); if ($query) { foreach ($query as $row) { $max_rooms = $row->max_rooms; $max_users = $row->max_users; // GET connected Participants $connected_users = get_connected_users($row->server_key, $row->api_url, $row->ip); $active_rooms = get_active_rooms($row->server_key, $row->api_url); if ($connected_users < $min_users) { $run_to = $row->id; $min_users = $connected_users; } //cases // max_users = 0 && max_rooms = 0 - UNLIMITED // active_rooms < max_rooms && active_users < max_users // active_rooms < max_rooms && max_users = 0 (UNLIMITED) // active_users < max_users && max_rooms = 0 (UNLIMITED) if ($max_rooms == 0 && $max_users == 0 || $max_users > $users_to_join + $connected_users && $active_rooms < $max_rooms || $active_rooms < $max_rooms && $max_users == 0 || $max_users > $users_to_join + $connected_users && $max_rooms == 0) { $run_to = $row->id; Database::get()->querySingle("UPDATE bbb_session SET running_at=?s WHERE meeting_id=?s", $row->id, $meeting_id); break; } } } if ($run_to == -1) { //WE SHOULD TAKE ACTION IF NO SERVER AVAILABLE DUE TO CAPACITY PROBLEMS // If no server available we select server with min connected users $temp_conn = 10000000; $query = Database::get()->queryArray("SELECT * FROM bbb_servers WHERE enabled='true' AND enable_recordings=?s ORDER BY weight ASC", $record); if ($query) { foreach ($query as $row) { // GET connected Participants $connected_users = get_connected_users($row->server_key, $row->api_url, $row->ip); if ($connected_users < $temp_conn) { $run_to = $row->id; $temp_conn = $connected_users; } } } Database::get()->querySingle("UPDATE bbb_session SET running_at=?d WHERE meeting_id=?s", $run_to, $meeting_id); } //we find the bbb server that will serv the session $res = Database::get()->querySingle("SELECT * FROM bbb_servers WHERE id=?d", $run_to); if ($res) { $salt = $res->server_key; $bbb_url = $res->api_url; $bbb = new BigBlueButton($salt, $bbb_url); $creationParams = array('meetingId' => $meeting_id, 'meetingName' => $title, 'attendeePw' => $att_pw, 'moderatorPw' => $mod_pw, 'welcomeMsg' => '', 'dialNumber' => '', 'voiceBridge' => '', 'webVoice' => '', 'logoutUrl' => '', 'maxParticipants' => '-1', 'record' => $record, 'duration' => '0'); // Create the meeting and get back a response: $result = $bbb->createMeetingWithXmlResponseArray($creationParams); // If it's all good, then we've interfaced with our BBB php api OK: if ($result == null) { // If we get a null response, then we're not getting any XML back from BBB. echo "<div class='alert-danger'>{$langBBBConnectionError}</div>"; exit; } else { if ($result['returncode'] == 'SUCCESS') { // Then do stuff ... //echo "<p>Meeting succesfullly created.</p>"; } else { echo "<div class='alert alert-danger'>{$langBBBCreationRoomError}.</div>"; exit; } } } }