- request for chat history when joining the meeting

This commit is contained in:
Richard Alam 2012-10-17 14:34:34 +00:00
parent ac297d2f1a
commit 0cfc9fabec
7 changed files with 43 additions and 23 deletions

View File

@ -19,17 +19,19 @@
package org.bigbluebutton.conference.service.chat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.red5.logging.Red5LoggerFactory;
import org.red5.server.api.Red5;
import org.bigbluebutton.conference.ClientMessage;
import org.red5.server.api.Red5; import org.bigbluebutton.conference.BigBlueButtonSession;
import org.bigbluebutton.conference.ClientMessage;
import org.bigbluebutton.conference.ConnectionInvokerService;
import org.bigbluebutton.conference.Constants;
import org.bigbluebutton.conference.service.chat.ChatRoomsManager;
import org.bigbluebutton.conference.service.chat.ChatRoom; import org.bigbluebutton.conference.service.chat.IChatRoomListener;
public class ChatApplication {
@ -65,8 +67,20 @@ public class ChatApplication {
return false;
}
public List<ChatMessageVO> getChatMessages(String room) {
return roomsManager.getChatMessages(room);
public void sendPublicChatHistory(String meetingID) {
List<ChatMessageVO> messages = roomsManager.getChatMessages(meetingID);
List<Map<String, Object>> msgs = new ArrayList<Map<String, Object>>();
for (ChatMessageVO v : messages) {
msgs.add(v.toMap());
}
Map<String, Object> messageToSend = new HashMap<String, Object>();
messageToSend.put("count", new Integer(msgs.size()));
messageToSend.put("messages", msgs);
ClientMessage m = new ClientMessage(ClientMessage.DIRECT, getBbbSession().getInternalUserID(), "ChatRequestMessageHistoryReply", messageToSend);
connInvokerService.sendMessage(m);
}
public void sendPublicMessage(String room, ChatMessageVO chatobj) {
@ -93,6 +107,10 @@ public class ChatApplication {
return Red5.getConnectionLocal().getScope().getName();
}
private BigBlueButtonSession getBbbSession() {
return (BigBlueButtonSession) Red5.getConnectionLocal().getAttribute(Constants.SESSION);
}
public void setConnInvokerService(ConnectionInvokerService connInvokerService) {
this.connInvokerService = connInvokerService;
}

View File

@ -18,7 +18,6 @@
*/
package org.bigbluebutton.conference.service.chat;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.red5.logging.Red5LoggerFactory; import org.red5.server.api.Red5;
@ -29,10 +28,9 @@ public class ChatService {
private ChatApplication application;
public void getChatMessages() {
String roomName = Red5.getConnectionLocal().getScope().getName();
List<ChatMessageVO> m = application.getChatMessages(roomName);
log.debug("NUM CHAT MSGS = " + m.size());
public void sendPublicChatHistory() {
String meetingID = Red5.getConnectionLocal().getScope().getName();
application.sendPublicChatHistory(meetingID);
}
public void sendPublicMessage(Map<String, Object> msg) {

View File

@ -30,7 +30,6 @@
import org.bigbluebutton.main.events.ModuleStartedEvent;
import org.bigbluebutton.modules.chat.events.ChatEvent;
import org.bigbluebutton.modules.chat.events.ConnectionEvent;
import org.bigbluebutton.modules.chat.events.QueryParticipantsEvent;
import org.bigbluebutton.modules.chat.events.SendPrivateChatMessageEvent;
import org.bigbluebutton.modules.chat.events.SendPublicChatMessageEvent;
import org.bigbluebutton.modules.chat.events.StartChatModuleEvent;
@ -68,13 +67,9 @@
<EventHandlers type="{SendPrivateChatMessageEvent.SEND_PRIVATE_CHAT_MESSAGE_EVENT}">
<MethodInvoker generator="{ChatMessageService}" method="sendPrivateMessage" arguments="{event.chatMessage}"/>
</EventHandlers>
<EventHandlers type="{QueryParticipantsEvent.QUERY_PARTICIPANTS_EVENT}">
</EventHandlers>
<EventHandlers type="{TranscriptEvent.LOAD_TRANSCRIPT}" >
<MethodInvoker generator="{ChatMessageService}" method="getPublicChatMessages"/>
</EventHandlers>
<Injectors target="{ChatMessageService}">

View File

@ -17,9 +17,9 @@ package org.bigbluebutton.modules.chat.services
sender.sendPrivateMessage(message);
}
public function getPublicMessages():void
public function getPublicChatMessages():void
{
sender.getPublicMessages();
sender.getPublicChatMessages();
}
}
}

View File

@ -29,11 +29,21 @@ package org.bigbluebutton.modules.chat.services
case "ChatReceivePrivateMessageCommand":
handleChatReceivePrivateMessageCommand(message);
break;
case "ChatRequestMessageHistoryReply":
handleChatRequestMessageHistoryReply(message);
break;
default:
// LogUtil.warn("Cannot handle message [" + messageName + "]");
}
}
private function handleChatRequestMessageHistoryReply(message:Object):void {
var msgCount:Number = message.count as Number;
for (var i:int = 0; i < msgCount; i++) {
handleChatReceivePublicMessageCommand(message.messages[i]);
}
}
private function handleChatReceivePublicMessageCommand(message:Object):void {
LogUtil.debug("Handling public chat message [" + message.message + "]");
var msg:ChatMessageVO = new ChatMessageVO();

View File

@ -11,11 +11,11 @@ package org.bigbluebutton.modules.chat.services
{
public var dispatcher:IEventDispatcher;
public function getPublicMessages():void
public function getPublicChatMessages():void
{
LogUtil.debug("Sending [chat.getPublicMessages] to server.");
var _nc:ConnectionManager = BBB.initConnectionManager();
_nc.sendMessage("chat.getChatMessages",
_nc.sendMessage("chat.sendPublicChatHistory",
function(result:String):void { // On successful result
LogUtil.debug(result);
},

View File

@ -67,7 +67,6 @@
import org.bigbluebutton.modules.chat.events.ChatOptionsEvent;
import org.bigbluebutton.modules.chat.events.PrivateChatMessageEvent;
import org.bigbluebutton.modules.chat.events.PublicChatMessageEvent;
import org.bigbluebutton.modules.chat.events.QueryParticipantsEvent;
import org.bigbluebutton.modules.chat.events.SendPrivateChatMessageEvent;
import org.bigbluebutton.modules.chat.events.SendPublicChatMessageEvent;
import org.bigbluebutton.modules.chat.model.ChatOptions;
@ -281,7 +280,7 @@
// Activates an audio alert for screen-reader users on private message reception
private function privateNotification(event:PrivateChatMessageEvent):void{
if (! UserManager.getInstance().getConference().amIThisUser(event.message.fromUserID)) {
if (! UsersUtil.isMe(event.message.fromUserID)) {
var newItem:Boolean = true;
// Check if there is already a notification of private messages from that user
if (privateWaiting.length){