fixed send private message

This commit is contained in:
Markos Calderon 2011-11-18 17:46:56 -08:00
parent 57677bf239
commit 33dcf0e2b3
6 changed files with 33 additions and 16 deletions

View File

@ -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<String> arguments = new ArrayList<String>();
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.");

View File

@ -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)
{

View File

@ -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;
}

View File

@ -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 = "<font color=\"#" + event.color + "\"><b>[" +
attributes.username +" - "+ event.time + "]</b> " + event.message + "</font><br/>";*/
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);
}

View File

@ -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);

View File

@ -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 {