213 lines
6.5 KiB
Plaintext
213 lines
6.5 KiB
Plaintext
|
<?xml version="1.0" encoding="utf-8"?>
|
||
|
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml"
|
||
|
xmlns:maps="org.bigbluebutton.modules.monitoring.maps.*"
|
||
|
xmlns:mate="http://mate.asfusion.com/"
|
||
|
implements="org.bigbluebutton.common.IBigBlueButtonModule"
|
||
|
creationComplete="init()">
|
||
|
|
||
|
<maps:MonitoringEventMap />
|
||
|
|
||
|
<mx:Script>
|
||
|
<![CDATA[
|
||
|
import org.bigbluebutton.common.LogUtil;
|
||
|
import mx.controls.Alert;
|
||
|
import com.asfusion.mate.events.Dispatcher;
|
||
|
import org.bigbluebutton.main.events.BBBEvent;
|
||
|
|
||
|
private var _moduleId:String = "MonitoringModule";
|
||
|
private var _moduleName:String = "Monitoring Module";
|
||
|
private static var _attributes:Object;
|
||
|
private static var globalDispatcher:Dispatcher = new Dispatcher();
|
||
|
|
||
|
// Login test
|
||
|
private static var isLoggedIn:Boolean = false; // flag to indicate if we successfully logged in
|
||
|
|
||
|
// Chat test
|
||
|
private static var chatMessageSent:String = "";
|
||
|
private static var chatTestSucceeded:Boolean = false;
|
||
|
|
||
|
// Voice test
|
||
|
private static var didUserJoin:Boolean = false;
|
||
|
|
||
|
// Presentation test
|
||
|
private static var didPresentationConvert:Boolean = false;
|
||
|
|
||
|
// Video test
|
||
|
private static var didVideoStart:Boolean = false;
|
||
|
|
||
|
private function init():void {
|
||
|
ExternalInterface.addCallback("checkLogin", checkLogin);
|
||
|
ExternalInterface.addCallback("sendRandomChatMessage", sendRandomChatMessage);
|
||
|
ExternalInterface.addCallback("checkChat", checkChat);
|
||
|
ExternalInterface.addCallback("joinVoiceConference", joinVoiceConference);
|
||
|
ExternalInterface.addCallback("checkVoice", checkVoice);
|
||
|
ExternalInterface.addCallback("testPresentationConversion", testPresentationConversion);
|
||
|
ExternalInterface.addCallback("startVideoConnection", startVideoConnection);
|
||
|
ExternalInterface.addCallback("playVideo", playVideo);
|
||
|
ExternalInterface.addCallback("checkVideo", checkVideo);
|
||
|
|
||
|
ExternalInterface.addCallback("startDeskshare", startDeskshare);
|
||
|
|
||
|
LogUtil.debug("Monitoring Module initialized");
|
||
|
}
|
||
|
|
||
|
public function get moduleId():String {
|
||
|
return _moduleId;
|
||
|
}
|
||
|
|
||
|
public function get moduleName():String {
|
||
|
return _moduleName;
|
||
|
}
|
||
|
|
||
|
public function get uri():String {
|
||
|
if (_attributes.mode == "PLAYBACK") {
|
||
|
return _attributes.uri + "/" + _attributes.playbackRoom;
|
||
|
}
|
||
|
|
||
|
return _attributes.uri + "/" + _attributes.room;
|
||
|
}
|
||
|
|
||
|
public function get username():String {
|
||
|
return _attributes.username;
|
||
|
}
|
||
|
|
||
|
public function get connection():NetConnection {
|
||
|
return _attributes.connection;
|
||
|
}
|
||
|
|
||
|
public function get mode():String {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
public function get userid():Number {
|
||
|
return _attributes.userid as Number;
|
||
|
}
|
||
|
|
||
|
public function get role():String {
|
||
|
return _attributes.userrole as String;
|
||
|
}
|
||
|
|
||
|
public function start(attributes:Object):void {
|
||
|
LogUtil.debug("Starting monitoring module");
|
||
|
LogUtil.debug("monitoring attr: " + attributes.username);
|
||
|
_attributes = attributes;
|
||
|
}
|
||
|
|
||
|
public function stop():void {
|
||
|
}
|
||
|
|
||
|
public static function handleLoginEvent(event:BBBEvent):void {
|
||
|
LogUtil.debug("RECEVING LOGIN EVENT!!!!!!!!!!!!!!!!!!");
|
||
|
if (event.type == BBBEvent.LOGIN_EVENT)
|
||
|
isLoggedIn = true;
|
||
|
}
|
||
|
|
||
|
private static function checkLogin():String {
|
||
|
return isLoggedIn.toString();
|
||
|
|
||
|
}
|
||
|
|
||
|
private static function checkChat():String {
|
||
|
if (chatTestSucceeded)
|
||
|
{
|
||
|
chatTestSucceeded = false;
|
||
|
return "true";
|
||
|
}
|
||
|
else
|
||
|
return chatTestSucceeded.toString();
|
||
|
}
|
||
|
|
||
|
public static function handleReceivedPublicChatMessageEvent(event:BBBEvent):void {
|
||
|
if (event.message.search(chatMessageSent) != -1)
|
||
|
chatTestSucceeded = true;
|
||
|
}
|
||
|
|
||
|
// Creates a random string and sends it as a chat message.
|
||
|
private static function sendRandomChatMessage():void {
|
||
|
chatMessageSent = generateRandomString(15);
|
||
|
globalDispatcher.dispatchEvent(new BBBEvent(BBBEvent.SEND_PUBLIC_CHAT_MESSAGE_EVENT, chatMessageSent));
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Voice
|
||
|
*/
|
||
|
private static function joinVoiceConference():void {
|
||
|
globalDispatcher.dispatchEvent(new BBBEvent(BBBEvent.JOIN_VOICE_CONFERENCE));
|
||
|
}
|
||
|
|
||
|
private static function checkVoice():String {
|
||
|
return didUserJoin.toString();
|
||
|
}
|
||
|
|
||
|
public static function handleAddedListenerEvent(event:BBBEvent):void {
|
||
|
if (event.message == _attributes.username) {
|
||
|
didUserJoin = true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Presentation
|
||
|
*/
|
||
|
|
||
|
private static function testPresentationConversion():String {
|
||
|
LogUtil.debug("testPresentationConversion !!!!!" + didPresentationConvert.toString());
|
||
|
return didPresentationConvert.toString();
|
||
|
}
|
||
|
|
||
|
public static function handlePresentationConversion(event:BBBEvent):void {
|
||
|
if (event.type == BBBEvent.PRESENTATION_CONVERTED) {
|
||
|
LogUtil.debug("Presentation has been converted!!!!!");
|
||
|
didPresentationConvert = true;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
// Obtained from: http://www.zedia.net/2008/generate-random-strings-in-as2-or-as3/
|
||
|
private static function generateRandomString(newLength:uint = 1, userAlphabet:String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"):String{
|
||
|
var alphabet:Array = userAlphabet.split("");
|
||
|
var alphabetLength:int = alphabet.length;
|
||
|
var randomLetters:String = "";
|
||
|
for (var i:uint = 0; i < newLength; i++){
|
||
|
randomLetters += alphabet[int(Math.floor(Math.random() * alphabetLength))];
|
||
|
}
|
||
|
return randomLetters;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Video
|
||
|
*/
|
||
|
|
||
|
private static function startVideoConnection():String {
|
||
|
globalDispatcher.dispatchEvent(new BBBEvent(BBBEvent.START_VIDEO_CONNECTION));
|
||
|
return "true";
|
||
|
}
|
||
|
|
||
|
private static function playVideo():String {
|
||
|
globalDispatcher.dispatchEvent(new BBBEvent(BBBEvent.START_VIDEO_STREAM, "640x480avatar.flv"));
|
||
|
return "true";
|
||
|
}
|
||
|
|
||
|
public static function videoHasStarted(e:Event):void {
|
||
|
didVideoStart = true;
|
||
|
}
|
||
|
|
||
|
private static function checkVideo():String {
|
||
|
return didVideoStart.toString();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Desktop Sharing
|
||
|
*/
|
||
|
|
||
|
private static function startDeskshare():String {
|
||
|
globalDispatcher.dispatchEvent(new BBBEvent(BBBEvent.START_DESKSHARE));
|
||
|
return "true";
|
||
|
}
|
||
|
|
||
|
]]>
|
||
|
</mx:Script>
|
||
|
|
||
|
</mx:Module>
|