Setupmediators for ListenersModule

git-svn-id: http://bigbluebutton.googlecode.com/svn/trunk@687 af16638f-c34d-0410-8cfa-b39d5352b314
This commit is contained in:
Richard Alam 2008-11-06 20:51:17 +00:00
parent 8cffb1b4be
commit f091e06cb3
5 changed files with 33 additions and 119 deletions

View File

@ -35,7 +35,7 @@
}
public function get uri():String {
return _attributes.uri + "/" + _attributes.room;
return _attributes.uri + "/85115"; //aredcode for now + _attributes.room;
}

View File

@ -1,10 +1,10 @@
package org.bigbluebutton.modules.viewers
package org.bigbluebutton.modules.listeners
{
import org.bigbluebutton.common.IBigBlueButtonModule;
import org.bigbluebutton.common.messaging.Endpoint;
import org.bigbluebutton.common.messaging.EndpointMessageConstants;
import org.bigbluebutton.common.messaging.Router;
import org.bigbluebutton.modules.viewers.model.ViewersProxy;
import org.bigbluebutton.modules.listeners.model.ListenersProxy;
import org.puremvc.as3.multicore.interfaces.IMediator;
import org.puremvc.as3.multicore.interfaces.INotification;
import org.puremvc.as3.multicore.patterns.mediator.Mediator;
@ -37,34 +37,33 @@ package org.bigbluebutton.modules.viewers
override public function listNotificationInterests():Array
{
return [
VoiceModuleConstants.STARTED,
VoiceModuleConstants.CONNECTED,
VoiceModuleConstants.DISCONNECTED,
VoiceModuleConstants.ADD_WINDOW,
VoiceModuleConstants.REMOVE_WINDOW
ListenersModuleConstants.STARTED,
ListenersModuleConstants.CONNECTED,
ListenersModuleConstants.DISCONNECTED,
ListenersModuleConstants.ADD_WINDOW,
ListenersModuleConstants.REMOVE_WINDOW
];
}
override public function handleNotification(notification:INotification):void
{
switch(notification.getName()){
case VoiceModuleConstants.STARTED:
case ListenersModuleConstants.STARTED:
trace(NAME + ":Sending MODULE_STARTED message to main");
_endpoint.sendMessage(EndpointMessageConstants.MODULE_STARTED,
EndpointMessageConstants.TO_MAIN_APP, _module.moduleId);
facade.sendNotification(VoiceModuleConstants.OPEN_JOIN_WINDOW);
break;
case VoiceModuleConstants.DISCONNECTED:
case ListenersModuleConstants.DISCONNECTED:
trace(NAME + ':Sending MODULE_STOPPED message to main');
_endpoint.sendMessage(EndpointMessageConstants.MODULE_STOPPED,
EndpointMessageConstants.TO_MAIN_APP, _module.moduleId);
break;
case VoiceModuleConstants.ADD_WINDOW:
case ListenersModuleConstants.ADD_WINDOW:
trace(NAME + ':Sending ADD_WINDOW message to main');
_endpoint.sendMessage(EndpointMessageConstants.ADD_WINDOW,
EndpointMessageConstants.TO_MAIN_APP, notification.getBody());
break;
case VoiceModuleConstants.REMOVE_WINDOW:
case ListenersModuleConstants.REMOVE_WINDOW:
trace(NAME + ':Sending REMOVE_WINDOW message to main');
_endpoint.sendMessage(EndpointMessageConstants.REMOVE_WINDOW,
EndpointMessageConstants.TO_MAIN_APP, notification.getBody());
@ -77,7 +76,7 @@ package org.bigbluebutton.modules.viewers
var msg : String = message.getHeader().MSG as String;
switch(msg){
case EndpointMessageConstants.CLOSE_WINDOW:
facade.sendNotification(VoiceModuleConstants.CLOSE_WINDOW);
facade.sendNotification(ListenersModuleConstants.CLOSE_WINDOW);
break;
case EndpointMessageConstants.OPEN_WINDOW:
//trace('Received OPEN_WINDOW message from ' + message.getHeader().SRC);
@ -86,8 +85,8 @@ package org.bigbluebutton.modules.viewers
}
}
private function get proxy():ViewersProxy {
return facade.retrieveProxy(ViewersProxy.NAME) as ViewersProxy;
private function get proxy():ListenersProxy {
return facade.retrieveProxy(ListenersProxy.NAME) as ListenersProxy;
}
}
}

View File

@ -19,22 +19,11 @@
*/
package org.bigbluebutton.modules.listeners
{
import org.bigbluebutton.common.messaging.InputPipe;
import org.bigbluebutton.common.messaging.OutputPipe;
import org.bigbluebutton.common.messaging.Router;
import org.bigbluebutton.main.MainApplicationConstants;
import org.bigbluebutton.modules.voiceconference.model.business.VoiceConfConnectResponder;
import org.bigbluebutton.modules.voiceconference.view.ListenersWindow;
import org.bigbluebutton.modules.voiceconference.view.ListenersWindowMediator;
import org.bigbluebutton.modules.voiceconference.view.recording.ListenersPlaybackMediator;
import org.puremvc.as3.multicore.interfaces.IMediator;
import org.puremvc.as3.multicore.patterns.mediator.Mediator;
import org.puremvc.as3.multicore.utilities.pipes.interfaces.IPipeMessage;
import org.puremvc.as3.multicore.utilities.pipes.messages.Message;
import org.puremvc.as3.multicore.utilities.pipes.plumbing.PipeListener;
/**
* The VoiceModuleMediator is a mediator class for the VoiceModule. It extends the Mediator class of the
* The ListenersModuleMediator is a mediator class for the VoiceModule. It extends the Mediator class of the
* PureMVC framework.
* @author dzgonjan
*
@ -42,104 +31,19 @@ package org.bigbluebutton.modules.listeners
public class ListenersModuleMediator extends Mediator implements IMediator
{
public static const NAME:String = "ListenersModuleMediator";
private var _module:ListenersModule;
private var outpipe : OutputPipe;
private var inpipe : InputPipe;
private var router : Router;
private var inpipeListener : PipeListener;
private var voiceWindow:ListenersWindow = new ListenersWindow();
private var module:VoiceModule;
private static const TO_VOICE_MODULE:String = "TO_VOICE_MODULE";
private static const FROM_VOICE_MODULE:String = "FROM_VOICE_MODULE";
private static const PLAYBACK_MESSAGE:String = "PLAYBACK_MESSAGE";
private static const PLAYBACK_MODE:String = "PLAYBACK_MODE";
/**
* The constructor. Registers this class with the VoiceModule
* @param view
*
*/
public function ListenersModuleMediator(view:VoiceModule)
public function ListenersModuleMediator(module:ListenersModule)
{
super(NAME,view);
module = view;
router = view.router;
inpipe = new InputPipe(TO_VOICE_MODULE);
outpipe = new OutputPipe(FROM_VOICE_MODULE);
inpipeListener = new PipeListener(this, messageReceiver);
inpipe.connect(inpipeListener);
router.registerOutputPipe(outpipe.name, outpipe);
router.registerInputPipe(inpipe.name, inpipe);
addWindow();
}
private function messageReceiver(message:IPipeMessage):void{
var msg:String = message.getHeader().MSG as String;
switch(msg){
case PLAYBACK_MODE:
switchToPlaybackMode();
break;
case PLAYBACK_MESSAGE:
playMessage(message.getBody() as XML);
break;
}
}
private function switchToPlaybackMode():void{
facade.removeMediator(VoiceConfConnectResponder.NAME);
var window:ListenersWindow =
(facade.retrieveMediator(ListenersWindowMediator.NAME) as ListenersWindowMediator).listenersWindow;
facade.removeMediator(ListenersWindowMediator.NAME);
facade.registerMediator(new ListenersPlaybackMediator(window));
}
private function playMessage(message:XML):void{
//Alert.show(message.toXMLString());
switch(String(message.@event)){
case ListenersPlaybackMediator.JOIN:
sendNotification(ListenersPlaybackMediator.JOIN, message);
break;
case ListenersPlaybackMediator.LEFT:
sendNotification(ListenersPlaybackMediator.LEFT, message);
break;
case ListenersPlaybackMediator.TALK:
sendNotification(ListenersPlaybackMediator.TALK, message);
break;
}
}
/**
* Adds the presentation window gui component to the main application shell via puremvc piping
*
*/
private function addWindow():void{
var msg:IPipeMessage = new Message(Message.NORMAL);
msg.setHeader({MSG:MainApplicationConstants.ADD_WINDOW_MSG, SRC: FROM_VOICE_MODULE,
TO: MainApplicationConstants.TO_MAIN });
msg.setPriority(Message.PRIORITY_HIGH);
voiceWindow.height = 200;
voiceWindow.width = 210;
voiceWindow.title = ListenersWindow.TITLE;
voiceWindow.showCloseButton = false;
module.activeWindow = voiceWindow;
msg.setBody(viewComponent as VoiceModule);
outpipe.write(msg);
}
/**
* Register this mediator with the voice facade
* @param key
*
*/
override public function initializeNotifier(key:String):void{
super.initializeNotifier(key);
facade.registerMediator(new ListenersWindowMediator(voiceWindow));
super(NAME);
_module = module;
}
}

View File

@ -19,6 +19,10 @@
*/
package org.bigbluebutton.modules.listeners.controller
{
import org.bigbluebutton.modules.listeners.ListenersModuleConstants;
import org.bigbluebutton.modules.listeners.ListenersModuleMediator;
import org.bigbluebutton.modules.listeners.model.ListenersProxy;
import org.bigbluebutton.modules.listeners.ListenersModuleEndpointMediator;
import org.puremvc.as3.multicore.interfaces.INotification;
import org.puremvc.as3.multicore.patterns.command.SimpleCommand;
@ -30,7 +34,13 @@ package org.bigbluebutton.modules.listeners.controller
public class StartupCommand extends SimpleCommand
{
override public function execute(notification:INotification):void{
var m:ListenersModule = notification.getBody() as ListenersModule;
// facade.registerMediator(new ListenersModuleMediator(m));
facade.registerMediator(new ListenersModuleEndpointMediator(m));
// facade.registerMediator(new JoinWindowMediator(m));
facade.registerProxy(new ListenersProxy(m));
sendNotification(ListenersModuleConstants.STARTED);
}
}
}

View File

@ -23,6 +23,7 @@ package org.bigbluebutton.modules.listeners.model
{
super(NAME);
_module = module;
connect();
}
override public function getProxyName():String