Skip to content

Commit

Permalink
Item10052: BBB first comments
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/BigBlueButtonPlugin@10081 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
ArneJoris authored and ArneJoris committed Nov 26, 2010
1 parent 653cb99 commit f83a76d
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 65 deletions.
24 changes: 14 additions & 10 deletions data/System/BigBlueButtonPlugin.txt
Expand Up @@ -17,13 +17,23 @@ The Configuration for this Plugin lets you define one or more meeting rooms (usu

This plugin also supports a REST interface, allowing other applications to use it to access virtual meeting rooms using foswiki authentication.

Please see the [[#InstallationInstructions][Installation Instructions]] for how to make this plugin work once you have installed and enabled it.

---++ REST Usage
* %SCRIPTURL{rest}%/BigBlueButtonPlugin/listRooms returns a list of rooms configured by this plugin.
* %SCRIPTURL{rest}%/BigBlueButtonPlugin/getJoinRoomUrl?room=Daisy returns a url that will log you into the room using your foswiki name.
* %SCRIPTURL{rest}%/BigBlueButtonPlugin/joinRoom?room=Daisy automatically logs you into that room using your foswiki name.
* %SCRIPTURL{rest}%/BigBlueButtonPlugin/getPeopleInRoom?room=Daisy returns a list of the people currently in the Daisy room.

---++ Examples

To get a list of all available meeting rooms, use
<verbatim>
%BBBJOINROOM{}%
</verbatim> which returns something like this:

%BBBJOINROOM{}%

If you have configured BigBlueButtonPlugin to create a meeting room named 'Lotus', the statement
<verbatim>
%BBBROOMNAME{Lotus}%
Expand Down Expand Up @@ -63,18 +73,12 @@ This plugin has the following configuration settings (set in %SCRIPTURL{configur
]
</verbatim>

The asterisk configuration on the BigBlueButton server must also declare your conference room names, otherwise you will have no audio. On the BBB server, in /etc/asterisk/bbb_extensions.conf, add:
<verbatim>
[bbb-voip]
...
exten => Daisy,1,Playback(conf-placeintoconf)
exten => Daisy,n,MeetMe(${EXTEN},cdMsT)
exten => Iris,1,Playback(conf-placeintoconf)
exten => Iris,n,MeetMe(${EXTEN},cdMsT)
</verbatim>
Note that the above example assumes that BBB has been configured to use the _MeetMe_ module for SIP.
The asterisk configuration on the BigBlueButton server must also declare your audioBridge numbers, otherwise you will have no audio. By default the asterisk configuration installed by BigBlueButton will use any five-digit number as audio bridge for conferencing.

---++ Installation Instructions
#InstallationInstructions

The default configuration parameters will create two rooms on a demo server maintained by the BigBlueButton crew for testing purposes. This lets you evaluate both the plugin and BigBlueButton without having to install anything else bug the plugin. After enabling the plugin, you will have to invoke either a REST function or a MACRO for the plugin to contact the BBB server, instruct it to create the meeting rooms and create topics for each room. Clicking [[%SCRIPTURL{rest}%/BigBlueButtonPlugin/listRooms][here]] will cause that for example.

%$INSTALL_INSTRUCTIONS%

Expand Down
169 changes: 115 additions & 54 deletions lib/Foswiki/Plugins/BigBlueButtonPlugin.pm
Expand Up @@ -38,8 +38,10 @@ our $NO_PREFS_IN_TOPIC = 1;
# Global variables
our $baseTopic;
our $baseWeb;
our $json;

use vars qw( $BBBServer $json );

################################################################################
sub initPlugin {
( $baseTopic, $baseWeb ) = @_;

Expand All @@ -63,59 +65,109 @@ sub initPlugin {

$json = JSON->new->allow_nonref;

require Foswiki::Plugins::BigBlueButtonPlugin::Core;
Foswiki::Plugins::BigBlueButtonPlugin::Core::init( $baseWeb, $baseTopic );
Foswiki::Func::writeDebug("BigBlueButtonPlugin initialized.");

return 1;
}

###############################################################################
sub finishPlugin {
return unless $BBBServer;

# We don't want to clean up all rooms and re-create them in
# non-persistent perl mode.
#$BBBServer->cleanup();
}

################################################################################
sub init {
return if $BBBServer;

eval 'use Foswiki::Plugins::BigBlueButtonPlugin::BBBServer';
if ($@) {
Foswiki::Func::writeWarning($@);
print STDERR $@;
}
else {
$BBBServer = new Foswiki::Plugins::BigBlueButtonPlugin::BBBServer();
$BBBServer->initialize();
}
}

################################################################################
sub _JOINROOM {

# Returns a URL that will let the currently logged in user
# join the specified room.
# Example: %BBBJOINROOM{Daisy}%
# Returns a URL that will let the currently logged in user
# join the specified room.
# Example: %BBBJOINROOM{Daisy}%
# When called with an emtpy room name, returns the list of URLs for all rooms.

my ( $session, $params, $theTopic, $theWeb ) = @_;
init();

my $roomName = $params->{_DEFAULT};
my $userName = Foswiki::Func::getWikiUserName();
return Foswiki::Func::renderText(
"[["
. Foswiki::Plugins::BigBlueButtonPlugin::Core::_getJoinRoomUrl(
$roomName, $userName )
. "][join $roomName conference room as $userName]]"
);

if ( $roomName == "" ) {
my @roomNames = $BBBServer->listRooms();

my @rooms = ();
if ( defined @roomNames ) {
foreach my $room (@roomNames) {
my $url = $BBBServer->getJoinRoomUrl( $room, $userName );
if ( defined $url ) {
push @rooms,
Foswiki::Func::renderText( "[["
. $url
. "][join $room conference room as $userName]]" );
}
}
}
return join( ", ", @rooms );
}
else {
my $url = $BBBServer->getJoinRoomUrl( $roomName, $userName );
if ( defined $url ) {
return Foswiki::Func::renderText( "[["
. $url
. "][join $roomName conference room as $userName]]" );
}
else {
return "No such room $roomName.";
}
}
}

################################################################################
sub _ROOMDETAILS {

# Returns a list of people in the specified room.
# Example: %BBBROOMDETAILS{Daisy}%
my ( $session, $params, $theTopic, $theWeb ) = @_;
init();

my $roomName = $params->{_DEFAULT};
my @people =
Foswiki::Plugins::BigBlueButtonPlugin::Core::_getPeopleInRoom($roomName);
return Foswiki::Func::renderText( join( ", ", @people ) );
my @people = $BBBServer->getPeopleInRoom($roomName);
if ( defined @people ) {
return Foswiki::Func::renderText( join( ", ", @people ) );
}
else {
return "";
}
}

################################################################################
sub _ROOMNAME {

# Given a topic name like GullConferenceRoom,
# returns link to that topic with tooltips.
my ( $session, $params, $theTopic, $theWeb ) = @_;

# %SEARCH{"name~'*ConferenceRoom'" excludetopic="%TOPIC%" type="query"
# scope="topic" nonoise="on" expandvariables="on" format=" * $percntBBBROOMNAME{ $topic }$percnt " }%
init();

my $roomName = $params->{_DEFAULT};
$roomName =~ s/^(.*)ConferenceRoom$/$1/g;
my %rooms = Foswiki::Plugins::BigBlueButtonPlugin::Core::_listRooms();
my %rooms = $BBBServer->listRooms();

Foswiki::Func::writeDebug(
"_ROOMNAME called for room $roomName (original $params->{_DEFAULT}).\n"
);
Foswiki::Func::writeDebug(
"_ROOMNAME rooms = " . Data::Dumper->Dump( [ \%rooms ] ) . "\n" );
return "" unless exists $rooms{$roomName};

eval 'require Foswiki::Plugins::ToolTipPlugin';
Expand Down Expand Up @@ -143,85 +195,94 @@ sub _ROOMNAME {
}
}

################################################################################
sub _RESTgetJoinRoomURL {

# Returns the url that will send the given person to the given room.
# Parameters: room
my ( $session, $plugin, $functionname, $response ) = @_;
init();

my $query = $session->{'request'};
my $userName = $session->{'remoteUser'};
my $room = $query->{'param'}->{'room'}[0];

my $url =
Foswiki::Plugins::BigBlueButtonPlugin::Core::_getJoinRoomUrl( $room,
$userName );
my $url = $BBBServer->getJoinRoomUrl( $room, $userName );
if ( defined $url ) {
my $r = {
'meetingRoomName' => $room,
'userName' => $userName,
'joinURL' => $url
};

my $r = {
'meetingRoomName' => $room,
'userName' => $userName,
'joinURL' => $url
};
$response->print( $json->pretty->encode($r) );
}
else {
$response->header( -status => 404 );
}

$response->print( $json->pretty->encode($r) );
return;
}

################################################################################
sub _RESTjoinRoom {

# Redirects the calller to the url that will send the given person to the given room.
# Parameters: room
my ( $session, $plugin, $functionname, $response ) = @_;
init();

my $query = $session->{'request'};
my $userName = $session->{'remoteUser'};
my $room = $query->{'param'}->{'room'}[0];

my $url =
Foswiki::Plugins::BigBlueButtonPlugin::Core::_getJoinRoomUrl( $room,
$userName );

return Foswiki::Func::redirectCgiQuery( undef, $url, 0 );
my $url = $BBBServer->getJoinRoomUrl( $room, $userName );
if ( defined $url ) {
return Foswiki::Func::redirectCgiQuery( undef, $url, 0 );
}
else {
$response->header( -status => 404 );
return;
}
}

################################################################################
sub _RESTgetPeopleInRoom {

# Returns a list of current participants.
my ( $session, $plugin, $functionname, $response ) = @_;
init();

my $query = $session->{'request'};
my $room = $query->{'param'}->{'room'}[0];

my $r = {
'meetingRoomName' => $room,
'participants' => [
Foswiki::Plugins::BigBlueButtonPlugin::Core::_getPeopleInRoom(
$room)
]
'participants' => [ $BBBServer->getPeopleInRoom($room) ]
};

$response->print( $json->pretty->encode($r) );

return;
}

################################################################################
sub _RESTlistRooms {
my ( $session, $plugin, $functionName, $response ) = @_;

# Returns a list of meeting rooms, with room name and list of current participants.
my ( $session, $plugin, $functionName, $response ) = @_;
init();

my $r = { 'meetingRooms' => [] };
foreach
my $room ( Foswiki::Plugins::BigBlueButtonPlugin::Core::_listRooms() )
{
push @{ $r->{'meetingRooms'} },
{
'meetingRoomName' => $room,
'participants' => [
Foswiki::Plugins::BigBlueButtonPlugin::Core::_getPeopleInRoom(
$room)
]
};
foreach my $room ( $BBBServer->listRooms() ) {
my @people = $BBBServer->getPeopleInRoom($room);
if ( defined @people ) {
push @{ $r->{'meetingRooms'} },
{
'meetingRoomName' => $room,
'participants' => [@people]
};
}
}

$response->print( $json->pretty->encode($r) );
Expand Down
2 changes: 1 addition & 1 deletion lib/Foswiki/Plugins/BigBlueButtonPlugin/MANIFEST
@@ -1,6 +1,6 @@
# Release manifest for BigBlueButtonPlugin
data/System/BigBlueButtonPlugin.txt 0644 Documentation
lib/Foswiki/Plugins/BigBlueButtonPlugin.pm 0644 Perl module
lib/Foswiki/Plugins/BigBlueButtonPlugin/Core.pm 0644 Perl module
lib/Foswiki/Plugins/BigBlueButtonPlugin/BBBServer.pm 0644 Perl module
lib/Foswiki/Plugins/BigBlueButtonPlugin/Config.spec config file for =configure=

0 comments on commit f83a76d

Please sign in to comment.