My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
SampleModule  
Creating a simple module in BigBlueButton 0.7 and above
Updated Oct 4, 2011 by spekto...@gmail.com

Getting Started

Follow the instructions on setting up your development environment.

Running the Example Code

There is an Example module in the code base. The main module class is in bbb-client/src/ExampleChatModule.mxml. It uses two simple classes which are located in bbb-client/src/org.bigbluebutton.modules.example

To get the ExampleChatModule working:

  • Set up your development environment correctly, making sure you can launch your bbb-client from Flash Builder 4.
  • Right click on your Flex Project, go to Properties>Modules and add src/ExampleChatModule.mxml to the list if it's not already there
  • Add the following code to the src/conf/config.xml file:
  • <module name="ExampleChatModule" url="ExampleChatModule.swf?v=56" 
    			uri="rtmp://192.168.0.219/bigbluebutton" 
    			host="http://192.168.0.219" 
    			onUserJoinedEvent="START" 
    			onUserLogoutEvent="STOP"
    />
  • In the same config.xml file, make sure the ExampleChatModule is also referenced as the loadNextProperty of the last loaded module (the module not already containing a loadNextModule property).
  • Launch your client and make sure you can see the new example module, and that you can send chat messages and receive them back.

Examining the Example Code

The ExampleChatModule demonstrates how to create a very simple module in BigBlueButton. The module contains a simple window with two text boxes and a button for sending messages. In total the module has 3 classes.

ExampleChatModule.mxml

You can use this class as a template for your future modules. The only relevant parts to you as a newbie to creating BigBlueButton modules are the two methods at the bottom - start() and stop(). The start function is called by the Main BigBlueButton Application when the module is loaded. It injects certain properties into the modules, such as the server connection to the red5 back-end of BigBlueButton, as well as the username and unique userid. The start() method here creates a new UI instance for our module - ExampleChatWindow.mxml. It also sends out an event, called OpenWindowEvent, which will get captured by the main application and the window will be displayed. The stop method is called when the user logs out or the application otherwise stops. You may perform any cleanup you need to do here.

ExampleChatWindow.mxml

The ExampleChatWindow contains the UI for our module. The UI components in the window (such as the text boxes and buttons) are declared as tags on the bottom. When the user clicks the "Send Message" button, the !sendNewMessage() method is executed, which appends whatever text there is in the input text box to the user name of the current user, and sends that message to the ExampleChatProxy class instance.

ExampleChatProxy.mxml

The ExampleChatProxy class has all the logic for communicating with the server, sending chat messages and receiving them. The class extracts the netConnection object from the attributes passed to it and uses the connection to the server to connect a RemoteSharedObject to the server. When the user clicks the "Send Message" button on the UI, the !sendMessage() method on the Proxy class is called, which updates the RemoteSharedObject on the server with the new message string value. The server then calls back all the client which are connected to that RemoteSharedObject with the updated string. In this case, the server calls the method !serverCallback(). This method updates the UI of our module, and the message appears in the window.

Compiling bbb-client Modules Under Ubuntu 10.04 using mxmlc

As you might know Ubuntu does not support Flash Builder, instead it has command to compile packages - mxmlc (Flex SDK). Sometimes compiling modules could be confusing, because of all libraries need to be included, also you need to move compiled file from directory it was compiled (where mxmlc is located) to directory it should be run from.

Here is the command that can help you to compile bbb-client module (for example let's compile ExampleChatModule):

mxmlc  /home/firstuser/dev/source/bigbluebutton/bigbluebutton-client/src/ExampleChatModule.mxml -sp /home/firstuser/dev/source/bigbluebutton/bigbluebutton-client/src  -l /home/firstuser/dev/source/bigbluebutton/bigbluebutton-client/libs -locale -accessible

Than you need to move swf file that was created in src directory to bin directory by typing:

mv  /home/firstuser/dev/source/bigbluebutton/bigbluebutton-client/src/ExampleChatModule.swf /home/firstuser/dev/source/bigbluebutton/bigbluebutton-client/bin

If you don't want to do this process every time you need to compile the Module, please look below to the script that will do this commands for you.

bbb-client Modules Bash Compiler

To facilitate the whole process here is what you should do (script only works if you have development environment installed and the user account name is "firstuser")
  1. Create new file call it compile-bbb-client-module (its ok not to use extension)
2. Copy and paste script below into the file
3. Run the script by opening Terminal and executing file that you have copied the script (e.g ./compile-bbb-client-module ExampleChatModule )
When it compiles just go to your BBB website and check if new module appeared.
Here is small bash script that will help you compiling bbb-client modules:
#!/bin/bash


#Checks number of arguments
if [ ! -n "$1" ]
then
  echo ""	
  echo "ERROR:Syntax for this command is ./compile-module <moduleName> (without extension just name) "
  echo " "
  exit 
fi  
# Shows current version of script
if [ "$1" == "-v" ]
	then
		echo " bbb-client Module Compiler"
		echo "     v 1.0  Created: September 28, 2011"
		echo "		by Anatoly Spektor  << http://myprogrammingblog.com  >>"
		exit
fi

#if number of arguments are correct check if file name that user passed exist
if [ -f "/home/firstuser/dev/source/bigbluebutton/bigbluebutton-client/src/$1.mxml" ]
then
 #if exist compile using mxmlc parameters such as sourcepath libraries etc
  mxmlc  /home/firstuser/dev/source/bigbluebutton/bigbluebutton-client/src/$1.mxml -sp /home/firstuser/dev/source/bigbluebutton/bigbluebutton-client/src  -l /home/firstuser/dev/source/bigbluebutton/bigbluebutton-client/libs -locale -accessible
 else
 	echo "$1.mxml does not exist, please choose another name"
fi

#if compilation went well compilable file should be in the directory
if [ -f "/home/firstuser/dev/source/bigbluebutton/bigbluebutton-client/src/$1.swf" ]
  then

	#IF  COMPILABLE FILE EXIST --> MOVE TO "BIN"
		
	mv  /home/firstuser/dev/source/bigbluebutton/bigbluebutton-client/src/$1.swf /home/firstuser/dev/source/bigbluebutton/bigbluebutton-client/bin
	#OUTPUT SUCCESS
	echo " ----------------------------------------------------- "
	echo "CONGRATULATIONS FILE: $1.swf  COMPILED AND MOVED TO:"
	echo " 						/home/firstuser/dev/source/bigbluebutton/bigbluebutton-client/bin " 
	echo " ----------------------------------------------------- "
  else
	#OUTPUT ERROR
	echo " ----------------------------"
	echo "$1.swf was not created"
	echo " ----------------------------"
  fi

To be able to run the script from anywhere do the following:

  1. open Terminal, type
    gedit ~/.bashrc
2. Go to the end and append the following (change the cd part to "cd the location of "compile-bbb-client-module" script ):
  alias compile-bbb-client-module='cd /home/firstuser/dev/add-ons; ./compile-bbb-client-module'
3. Close .bashrc file and source it by typing in terminal:
  source ~/.bashrc
4. Run the script by typing:
  compile-bbb-client-module ExampleChatModule
Now you have a script that can compile any bbb-client's module. Hope this will facilitate your work.
Powered by Google Project Hosting