|
SampleModule
Creating a simple module in BigBlueButton 0.7 and above
Getting StartedFollow the instructions on setting up your development environment. Running the Example CodeThere 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:
<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" /> Examining the Example CodeThe 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.mxmlYou 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.mxmlThe 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.mxmlThe 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 mxmlcAs 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 CompilerTo 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")
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:
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. | |