From e7cb88cf29cb730a218b87d0849faaf1b6836388 Mon Sep 17 00:00:00 2001 From: Hugo Lazzari Date: Fri, 19 Jul 2013 10:05:24 -0300 Subject: [PATCH] Refactoring guest --- .../main/events/RefreshGuestEvent.as | 3 +- .../main/events/RemoveGuestFromViewEvent.as | 34 +++++++++++++++++++ .../main/maps/ApplicationEventMap.mxml | 10 +++--- .../src/org/bigbluebutton/main/model/Guest.as | 8 ++--- .../bigbluebutton/main/model/GuestManager.as | 8 +++-- .../main/model/users/UsersSOService.as | 8 ++--- .../bigbluebutton/main/views/GuestWindow.mxml | 21 ++++++------ .../main/views/MainApplicationShell.mxml | 13 ++++--- 8 files changed, 68 insertions(+), 37 deletions(-) create mode 100644 bigbluebutton-client/src/org/bigbluebutton/main/events/RemoveGuestFromViewEvent.as diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/events/RefreshGuestEvent.as b/bigbluebutton-client/src/org/bigbluebutton/main/events/RefreshGuestEvent.as index 266ef9485a..fc552ad934 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/main/events/RefreshGuestEvent.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/events/RefreshGuestEvent.as @@ -24,8 +24,7 @@ package org.bigbluebutton.main.events { public static const REFRESH_GUEST_VIEW:String = "RefreshGuestView"; - - public listOfGuests:Object; + public var listOfGuests:Object; public function RefreshGuestEvent(type:String = REFRESH_GUEST_VIEW) { diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/events/RemoveGuestFromViewEvent.as b/bigbluebutton-client/src/org/bigbluebutton/main/events/RemoveGuestFromViewEvent.as new file mode 100644 index 0000000000..c755ddded0 --- /dev/null +++ b/bigbluebutton-client/src/org/bigbluebutton/main/events/RemoveGuestFromViewEvent.as @@ -0,0 +1,34 @@ +/** +* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ +* +* Copyright (c) 2010 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 2.1 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 . +* +*/ +package org.bigbluebutton.main.events +{ + import flash.events.Event; + + public class RemoveGuestFromViewEvent extends Event + { + public static const REMOVE_GUEST:String = "RemoveGuest"; + + public var userid:Number; + + public function RemoveGuestFromViewEvent(type:String = REMOVE_GUEST) + { + super(type, true, false); + } + } +} \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/maps/ApplicationEventMap.mxml b/bigbluebutton-client/src/org/bigbluebutton/main/maps/ApplicationEventMap.mxml index b57b5707ce..9568dd3ffb 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/maps/ApplicationEventMap.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/main/maps/ApplicationEventMap.mxml @@ -43,11 +43,6 @@ - - - - - @@ -93,8 +88,12 @@ + + + + @@ -183,6 +182,7 @@ import org.bigbluebutton.main.events.ResponseModeratorEvent; import org.bigbluebutton.main.events.AddGuestEvent; import org.bigbluebutton.main.events.ResponseModeratorEvent; + import org.bigbluebutton.main.events.RemoveGuestRequestEvent; ]]> diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/Guest.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/Guest.as index 9f2fbbef5f..94e357e915 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/main/model/Guest.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/Guest.as @@ -23,8 +23,7 @@ package org.bigbluebutton.main.model public class Guest { private var listOfGuests:Object = new Object(); - private var numberOfGuests = 0; - private var dispatcher; + private var numberOfGuests:Number = 0; public function hasGuest():Boolean { return numberOfGuests > 0; @@ -34,9 +33,8 @@ package org.bigbluebutton.main.model return numberOfGuests; } - public function addGuest(userID:Number, userName:String):void { - var guest:Object = {userid:userID, username:userName}; - listOfGuests.addItem(guest); + public function addGuest(userid:Number, username:String):void { + listOfGuests[userid] = username; numberOfGuests++; } diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/GuestManager.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/GuestManager.as index 914c7f9b26..a70df0fb7f 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/main/model/GuestManager.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/GuestManager.as @@ -23,12 +23,14 @@ package org.bigbluebutton.main.model import com.asfusion.mate.events.Dispatcher; import org.bigbluebutton.main.events.RefreshGuestEvent; import org.bigbluebutton.main.events.AddGuestEvent; + import org.bigbluebutton.main.events.RemoveGuestFromViewEvent; public class GuestManager { private var guest:Guest; + private var dispatcher:Dispatcher; - function GuestManager(dispatcher:Dispatcher) { + function GuestManager() { this.dispatcher = new Dispatcher(); this.guest = new Guest(); } @@ -48,7 +50,7 @@ package org.bigbluebutton.main.model guest.removeAllGuests(); } - private function removeGuetFromView(userid:Number):void { + private function removeGuestFromView(userid:Number):void { var removeGuestFromViewEvent:RemoveGuestFromViewEvent = new RemoveGuestFromViewEvent(); removeGuestFromViewEvent.userid = userid; dispatcher.dispatchEvent(removeGuestFromViewEvent); @@ -56,7 +58,7 @@ package org.bigbluebutton.main.model public function removeGuest(userid:Number):void { guest.remove(userid); - removeGuetFromView(userid); + removeGuestFromView(userid); } } } diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/UsersSOService.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/UsersSOService.as index 09a8d5206b..8b0086347e 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/UsersSOService.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/UsersSOService.as @@ -409,11 +409,11 @@ package org.bigbluebutton.main.model.users { for(i = 0; i < users.length; i++) { if(users[i] != "") { var pairSplited:Array = users[i].split("!2"); - var newGuestEvent:NewGuestEvent = new NewGuestEvent(NewGuestEvent.NEW_GUEST_EVENT); - newGuestEvent.userid = new Number(pairSplited[0]); - newGuestEvent.name = pairSplited[1]; + var addGuestEvent:AddGuestEvent = new AddGuestEvent(AddGuestEvent.ADD_GUEST); + addGuestEvent.userid = new Number(pairSplited[0]); + addGuestEvent.name = pairSplited[1]; var dispatcher:Dispatcher = new Dispatcher(); - dispatcher.dispatchEvent(newGuestEvent); + dispatcher.dispatchEvent(addGuestEvent); } } } diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/views/GuestWindow.mxml b/bigbluebutton-client/src/org/bigbluebutton/main/views/GuestWindow.mxml index df9e8e61c7..c0511f2868 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/views/GuestWindow.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/main/views/GuestWindow.mxml @@ -27,7 +27,7 @@ - + diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/views/MainApplicationShell.mxml b/bigbluebutton-client/src/org/bigbluebutton/main/views/MainApplicationShell.mxml index 2120a48903..0cca6dc002 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/views/MainApplicationShell.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/main/views/MainApplicationShell.mxml @@ -47,7 +47,7 @@ -