- handle private chat

This commit is contained in:
Richard Alam 2017-10-02 14:43:18 -07:00
parent 8d38f7fcc2
commit 3194735a0b
3 changed files with 39 additions and 4 deletions

View File

@ -0,0 +1,17 @@
package org.bigbluebutton.modules.chat.events
{
import flash.events.Event;
public class PrivateGroupChatCreatedEvent extends Event
{
public static const PRIVATE_GROUP_CHAT_CREATED_EVENT:String = "private group chat create event";
public var chatId:String;
public function PrivateGroupChatCreatedEvent(chatId:String)
{
super(PRIVATE_GROUP_CHAT_CREATED_EVENT, false, false);
this.chatId = chatId;
}
}
}

View File

@ -25,6 +25,7 @@ package org.bigbluebutton.modules.chat.maps {
import org.bigbluebutton.common.events.OpenWindowEvent;
import org.bigbluebutton.core.Options;
import org.bigbluebutton.core.model.LiveMeeting;
import org.bigbluebutton.modules.chat.events.PrivateGroupChatCreatedEvent;
import org.bigbluebutton.modules.chat.model.ChatModel;
import org.bigbluebutton.modules.chat.model.ChatOptions;
import org.bigbluebutton.modules.chat.model.GroupChat;
@ -101,7 +102,7 @@ package org.bigbluebutton.modules.chat.maps {
var winMapper:GroupChatWindowMapper = _windowMapper[MAIN_CHAT_WINID];
winMapper.addChatBox(gcBoxMapper);
globalDispatcher.dispatchEvent(new PrivateGroupChatCreatedEvent(chatId));
}
public function createNewGroupChat(chatId: String):void {

View File

@ -30,6 +30,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
verticalScrollPolicy="off" xmlns:common="org.bigbluebutton.common.*">
<fx:Declarations>
<mate:Listener type="{PrivateGroupChatCreatedEvent.PRIVATE_GROUP_CHAT_CREATED_EVENT}" method="handlePrivateGroupChatCreatedEvent"/>
<mate:Listener type="{PrivateChatMessageEvent.PRIVATE_CHAT_MESSAGE_EVENT}" method="handlePrivateChatMessageEvent"/>
<mate:Listener type="{PublicChatMessageEvent.PUBLIC_CHAT_MESSAGE_EVENT}" method="handlePublicChatMessageEvent"/>
<mate:Listener type="{EventConstants.START_PRIVATE_CHAT}" method="handleStartPrivateChatMessageEvent"/>
@ -41,14 +42,18 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<fx:Script>
<![CDATA[
import com.asfusion.mate.events.Dispatcher;
import com.asfusion.mate.events.Dispatcher;
import flash.events.Event;
import flash.events.FocusEvent;
import flash.media.Sound;
import mx.controls.Button;
import mx.core.INavigatorContent;
import flexlib.controls.tabBarClasses.SuperTab;
import flexlib.events.SuperTabEvent;
import org.bigbluebutton.core.EventConstants;
import org.bigbluebutton.core.Options;
import org.bigbluebutton.core.UsersUtil;
@ -59,6 +64,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
import org.bigbluebutton.modules.chat.events.ChatSaveEvent;
import org.bigbluebutton.modules.chat.events.ChatToolbarButtonEvent;
import org.bigbluebutton.modules.chat.events.PrivateChatMessageEvent;
import org.bigbluebutton.modules.chat.events.PrivateGroupChatCreatedEvent;
import org.bigbluebutton.modules.chat.events.PublicChatMessageEvent;
import org.bigbluebutton.modules.chat.model.ChatOptions;
import org.bigbluebutton.util.i18n.ResourceUtil;
@ -178,6 +184,17 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
}
}
private function handlePrivateGroupChatCreatedEvent(event:PrivateGroupChatCreatedEvent):void {
if (! userHasChatBox(event.chatId)) {
// Open a private chat tab.
openChatBoxFor(event.chatId, false);
}
// See if the chatbox is not in focus and notify user about the message.
notifyUserOfNewMessage(event.chatId);
privateNotification(event.chatId);
}
private function handlePrivateChatMessageEvent(event:PrivateChatMessageEvent):void {
// This message is from me. Ignore as a chatbox has already been created for this
// private chat and that chatbox will handle this message.
@ -275,8 +292,8 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
focusSwitchTimer.start();
}
private function userHasChatBox(userID:String):Boolean {
var chatBox:ChatBox = chatTabs.getChildByName(userID) as ChatBox;
private function userHasChatBox(chatId:String):Boolean {
var chatBox:ChatBox = chatTabs.getChildByName(chatId) as ChatBox;
if (chatBox != null) return true;
return false;
}