From 33dcf0e2b3a538207eb1b81c2ab07009c8e637c4 Mon Sep 17 00:00:00 2001 From: Markos Calderon Date: Fri, 18 Nov 2011 17:46:56 -0800 Subject: [PATCH] fixed send private message --- .../conference/service/chat/ChatService.java | 7 ++++++- .../chat/events/PrivateChatMessageEvent.as | 4 ++-- .../bigbluebutton/modules/chat/model/MessageVO.as | 6 +++--- .../modules/chat/services/PrivateChatService.as | 15 ++++++++++++--- .../services/PrivateChatSharedObjectService.as | 15 +++++++++------ .../modules/chat/views/ChatView.mxml | 2 +- 6 files changed, 33 insertions(+), 16 deletions(-) diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/chat/ChatService.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/chat/ChatService.java index caafd140cc..aae182fc37 100755 --- a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/chat/ChatService.java +++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/chat/ChatService.java @@ -44,13 +44,18 @@ public class ChatService { application = a; } - public void privateMessage(String message, String sender, String receiver){ + public void privateMessage(String message, String username, String color, String time, String language, String userid, String sender, String receiver){ log.debug("Received private message: " + message + " from " + sender + " to " + receiver + ". The client scope is: " + Red5.getConnectionLocal().getScope().getName()); ISharedObject sharedObject = application.handler.getSharedObject(Red5.getConnectionLocal().getScope(), receiver); if (sharedObject != null) { ArrayList arguments = new ArrayList(); arguments.add(sender); arguments.add(message); + arguments.add(username); + arguments.add(color); + arguments.add(time); + arguments.add(language); + arguments.add(userid); sharedObject.sendMessage("messageReceived", arguments); } else { log.debug("Not sending private message from " + sender + " to " + receiver + " as the user may have already left."); diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/events/PrivateChatMessageEvent.as b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/events/PrivateChatMessageEvent.as index 2072cb14f6..0f702563c0 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/events/PrivateChatMessageEvent.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/events/PrivateChatMessageEvent.as @@ -28,8 +28,8 @@ package org.bigbluebutton.modules.chat.events public static const PRIVATE_CHAT_MESSAGE_EVENT:String = 'PRIVATE_CHAT_MESSAGE_EVENT'; - //public var message:MessageVO; - public var chatobj:ChatObject; + public var message:MessageVO; + //public var chatobj:ChatObject; public function PrivateChatMessageEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false) { diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/model/MessageVO.as b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/model/MessageVO.as index c14b006c2e..6c22cad54c 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/model/MessageVO.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/model/MessageVO.as @@ -20,13 +20,13 @@ package org.bigbluebutton.modules.chat.model { public class MessageVO { - public var message:String; + public var chatobj:ChatObject; public var recepient:String; public var sender:String; - public function MessageVO(message:String, sender:String, recepient:String) + public function MessageVO(chatobj:ChatObject, sender:String, recepient:String) { - this.message = message; + this.chatobj = chatobj; this.recepient = recepient; this.sender = sender; } diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/services/PrivateChatService.as b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/services/PrivateChatService.as index 1606087df4..99f3be201e 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/services/PrivateChatService.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/services/PrivateChatService.as @@ -20,7 +20,9 @@ package org.bigbluebutton.modules.chat.services { import flash.events.IEventDispatcher; + import org.bigbluebutton.main.views.LanguageSelector; import org.bigbluebutton.modules.chat.events.SendPrivateChatMessageEvent; + import org.bigbluebutton.modules.chat.model.ChatObject; import org.bigbluebutton.modules.chat.model.MessageVO; @@ -49,11 +51,18 @@ package org.bigbluebutton.modules.chat.services public function sendChatMessageEvent(event:SendPrivateChatMessageEvent):void { trace("Receive receivedSendPrivateChatMessageEvent"); - var newMessage:String; /*newMessage = "[" + attributes.username +" - "+ event.time + "] " + event.message + "
";*/ - newMessage = event.message + "|" + attributes.username + "|" + event.color + "|" + event.time + "|" + event.language + "|" + attributes.userid; - var messageVO:MessageVO = new MessageVO(newMessage, attributes.userid, event.toUser); + var chatobj:ChatObject = new ChatObject(); + chatobj.message = event.message; + chatobj.username = attributes.username; + chatobj.color = event.color; + chatobj.time = event.time; + chatobj.language = event.language; + chatobj.userid = attributes.userid; + + var messageVO:MessageVO = new MessageVO(chatobj, attributes.userid, event.toUser); + chatSOService.sendMessage(messageVO); } diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/services/PrivateChatSharedObjectService.as b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/services/PrivateChatSharedObjectService.as index 3f5a064bd0..17c417857b 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/services/PrivateChatSharedObjectService.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/services/PrivateChatSharedObjectService.as @@ -98,24 +98,27 @@ package org.bigbluebutton.modules.chat.services } public function sendMessage(message:MessageVO):void{ - connection.call("chat.privateMessage", privateResponder, message.message, message.sender , message.recepient); + connection.call("chat.privateMessage", privateResponder, message.chatobj.message, message.chatobj.username, message.chatobj.color, message.chatobj.time, message.chatobj.language, message.chatobj.userid, message.sender , message.recepient); sendMessageToSelf(message); } private function sendMessageToSelf(message:MessageVO):void { - messageReceived(message.recepient, message.message); + messageReceived(message.recepient, message.chatobj.message,message.chatobj.username,message.chatobj.color,message.chatobj.time,message.chatobj.language,message.chatobj.userid); } - public function messageReceived(from:String, message:String):void { + public function messageReceived(from:String, message:String, username:String, color:String, time:String, language:String, userid:String):void { var event:PrivateChatMessageEvent = new PrivateChatMessageEvent(PrivateChatMessageEvent.PRIVATE_CHAT_MESSAGE_EVENT); var chatobj:ChatObject = new ChatObject(); chatobj.message = message; - chatobj.username = from; + chatobj.username = username; + chatobj.color = color; + chatobj.time = time; + chatobj.language = language; chatobj.userid = userid; - event.chatobj = chatobj; - //event.message = new MessageVO(message, from, userid); + event.message = new MessageVO(chatobj, from, userid); + //trace("Sending private message " + message); var globalDispatcher:Dispatcher = new Dispatcher(); globalDispatcher.dispatchEvent(event); diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatView.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatView.mxml index 3a198e0dd0..2298b80a8f 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatView.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatView.mxml @@ -372,7 +372,7 @@ LogUtil.debug("Got PrivateChatMessageEvent"); if (!this.focus) ExternalInterface.call("startblink", ResourceUtil.getInstance().getString('bbb.chat.privateMsgAwaiting'), ResourceUtil.getInstance().getString('bbb.chat.privateMsgAwaiting2')); - showMessage(event.chatobj.userid, event.chatobj, autoTranslation); + showMessage(event.message.sender, event.message.chatobj, autoTranslation); } private function participantHasChatBox(id:String):Boolean {