bigbluebutton-Github/bigbluebutton-client/src/BigBlueButtonTest.mxml

211 lines
6.2 KiB
XML
Executable File

<?xml version="1.0" encoding="utf-8"?>
<!--
BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below).
This program is free software; you can redistribute it and/or modify it under the
terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 3.0 of the License, or (at your option) any later
version.
BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:views="org.bigbluebutton.main.views.*"
xmlns:maps="org.bigbluebutton.main.maps.*"
xmlns:mate="http://mate.asfusion.com/"
xmlns:m="library://melomel/2010"
pageTitle="BigBlueButton"
layout="absolute"
preloader="org.bigbluebutton.main.model.BigBlueButtonPreloader">
<mx:Script>
<![CDATA[
import com.asfusion.mate.events.Dispatcher;
import mx.managers.HistoryManager;
import mx.managers.IDragManager;
import org.bigbluebutton.main.events.BBBEvent;
import org.bigbluebutton.util.i18n.ResourceUtil;
private var langResources:ResourceUtil = ResourceUtil.getInstance();
public var myFoo:String = "bar";
/**
* Thse two lines are workaround for this. (ralam - Nov 8, 2008)
* http://gregjessup.com/flex-3-advanceddatagrid-cannot-convert-mxmanagersdragmanagerimpl-to-mxmanagersidragmanager/
* http://butterfliesandbugs.wordpress.com/2007/10/25/workaround-for-error-when-loading-popups-from-modules/
*/
private var iDragManager:IDragManager;
/** another workaround - for this issue: https://bugs.adobe.com/jira/browse/SDK-13121*/
private var hist:HistoryManager
private function handleChatEvent(e:Event):void {
trace('Got CHAT_EVENT');
}
public function setFoo(f:String):void {
myFoo = f;
}
/******************************
* Testing
******************************/
private 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;
public function handleLoginEvent(event:BBBEvent):void {
LogUtil.debug("******************* Received loggedin event");
isLoggedIn = true;
LogUtil.debug("******************* Received loggedin event " + isLoggedIn.toString());
}
public function checkLogin():String {
LogUtil.debug("******************* " + isLoggedIn.toString());
return isLoggedIn.toString();
}
public function checkChat():String {
if (chatTestSucceeded)
{
chatTestSucceeded = false;
return "true";
}
else
return chatTestSucceeded.toString();
}
public function handleReceivedPublicChatMessageEvent(event:BBBEvent):void {
if (event.message.search(chatMessageSent) != -1)
chatTestSucceeded = true;
}
// Creates a random string and sends it as a chat message.
public function sendRandomChatMessage():void {
chatMessageSent = generateRandomString(15);
globalDispatcher.dispatchEvent(new BBBEvent(BBBEvent.SEND_PUBLIC_CHAT_MESSAGE_EVENT, chatMessageSent));
}
/**
* Voice
*/
public function joinVoiceConference():void {
globalDispatcher.dispatchEvent(new BBBEvent(BBBEvent.JOIN_VOICE_CONFERENCE));
}
public function checkVoice():String {
return didUserJoin.toString();
}
public function handleAddedListenerEvent(event:BBBEvent):void {
// if (event.message == _attributes.username) {
didUserJoin = true;
// }
}
/**
* Presentation
*/
public function testPresentationConversion():String {
return didPresentationConvert.toString();
}
public function handlePresentationConversion(event:Event):void {
didPresentationConvert = true;
}
// Obtained from: http://www.zedia.net/2008/generate-random-strings-in-as2-or-as3/
private 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
*/
public function startVideoConnection():String {
globalDispatcher.dispatchEvent(new BBBEvent(BBBEvent.START_VIDEO_CONNECTION));
return "true";
}
public function playVideo():String {
globalDispatcher.dispatchEvent(new BBBEvent(BBBEvent.START_VIDEO_STREAM, "640x480avatar.flv"));
return "true";
}
public function videoHasStarted(e:Event):void {
didVideoStart = true;
}
public function checkVideo():String {
return didVideoStart.toString();
}
/**
* Desktop Sharing
*/
public function startDeskshare():String {
globalDispatcher.dispatchEvent(new BBBEvent(BBBEvent.START_DESKSHARE));
return "true";
}
]]>
</mx:Script>
<m:Melomel/>
<maps:ApplicationEventMap />
<views:MainApplicationShell id="mainShell"/>
<mate:Listener type="{BBBEvent.LOGIN_EVENT}" method="handleLoginEvent"/>
<mate:Listener type="{BBBEvent.RECEIVED_PUBLIC_CHAT_MESSAGE_EVENT}" method="handleReceivedPublicChatMessageEvent"/>
<mate:Listener type="{BBBEvent.USER_VOICE_JOINED}" method="handleAddedListenerEvent"/>
<mate:Listener type="{BBBEvent.VIDEO_STARTED}" method="videoHasStarted"/>
</mx:Application>