Revert "Merge branch 'upgrade-to-scala-2.11' of https://github.com/antobinary/bigbluebutton into upgrade-to-scala-2.11"

This reverts commit 117369dcda, reversing
changes made to 6d786f1422.
This commit is contained in:
Richard Alam 2015-05-20 10:23:06 -07:00
parent 117369dcda
commit 11a51995e7
6 changed files with 69 additions and 297 deletions

View File

@ -1,7 +1,7 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* Copyright (c) 2015 BigBlueButton Inc. and by respective authors (see below).
* Copyright (c) 2012 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
@ -21,7 +21,7 @@ package org.bigbluebutton.conference.service.chat;
import java.util.Map;
import org.bigbluebutton.core.api.Red5BBBInGw;
import org.bigbluebutton.core.api.IBigBlueButtonInGW;
import org.red5.logging.Red5LoggerFactory;
import org.slf4j.Logger;
@ -29,23 +29,23 @@ import org.slf4j.Logger;
public class ChatApplication {
private static Logger log = Red5LoggerFactory.getLogger( ChatApplication.class, "bigbluebutton" );
private Red5BBBInGw Red5BBBInGw;
private IBigBlueButtonInGW bbbInGW;
public void setBigBlueButtonInGW(Red5BBBInGw inGW) {
Red5BBBInGw = inGW;
public void setBigBlueButtonInGW(IBigBlueButtonInGW inGW) {
bbbInGW = inGW;
}
public void sendPublicChatHistory(String meetingID, String requesterID) {
// Just hardcode as we don't really need it for flash client. (ralam may 7, 2014)
String replyTo = meetingID + "/" + requesterID;
Red5BBBInGw.getChatHistory(meetingID, requesterID, replyTo);
bbbInGW.getChatHistory(meetingID, requesterID, replyTo);
}
public void sendPublicMessage(String meetingID, String requesterID, Map<String, String> message) {
Red5BBBInGw.sendPublicMessage(meetingID, requesterID, message);
bbbInGW.sendPublicMessage(meetingID, requesterID, message);
}
public void sendPrivateMessage(String meetingID, String requesterID, Map<String, String> message) {
Red5BBBInGw.sendPrivateMessage(meetingID, requesterID, message);
bbbInGW.sendPrivateMessage(meetingID, requesterID, message);
}
}

View File

@ -1,14 +1,13 @@
package org.bigbluebutton.conference.service.chat;
import org.bigbluebutton.conference.service.messaging.GetChatHistory;
import org.bigbluebutton.conference.service.messaging.MessagingConstants;
import org.bigbluebutton.conference.service.messaging.SendPrivateChatMessage;
import org.bigbluebutton.conference.service.messaging.SendPublicChatMessage;
import org.bigbluebutton.conference.service.messaging.redis.MessageHandler;
import com.google.gson.JsonParser;
import com.google.gson.JsonObject;
import java.util.Map;
import java.util.HashMap;
import org.bigbluebutton.core.api.IBigBlueButtonInGW;
public class ChatMessageListener implements MessageHandler{
@ -22,23 +21,55 @@ public class ChatMessageListener implements MessageHandler{
@Override
public void handleMessage(String pattern, String channel, String message) {
if (channel.equalsIgnoreCase(MessagingConstants.TO_CHAT_CHANNEL)) {
JsonParser parser = new JsonParser();
JsonObject obj = (JsonObject) parser.parse(message);
JsonObject headerObject = (JsonObject) obj.get("header");
JsonObject payloadObject = (JsonObject) obj.get("payload");
JsonObject messageObject = (JsonObject) payloadObject.get("message");
if (obj.has("header") && obj.has("payload")) {
JsonObject header = (JsonObject) obj.get("header");
String eventName = headerObject.get("name").toString();
eventName = eventName.replace("\"", "");
if (header.has("name")) {
String messageName = header.get("name").getAsString();
if (GetChatHistory.GET_CHAT_HISTORY_REQUEST.equals(messageName)) {
GetChatHistory msg = GetChatHistory.fromJson(message);
bbbGW.getChatHistory(msg.meetingId, msg.requesterId, msg.replyTo);
} else if (SendPublicChatMessage.SEND_PUBLIC_CHAT_MESSAGE.equals(messageName)){
SendPublicChatMessage msg = SendPublicChatMessage.fromJson(message);
bbbGW.sendPublicMessage(msg.meetingId, msg.requesterId, msg.messageInfo);
} else if (SendPrivateChatMessage.SEND_PRIVATE_CHAT_MESSAGE.equals(messageName)){
SendPrivateChatMessage msg = SendPrivateChatMessage.fromJson(message);
bbbGW.sendPrivateMessage(msg.meetingId, msg.requesterId, msg.messageInfo);
if (eventName.equalsIgnoreCase(MessagingConstants.SEND_PUBLIC_CHAT_MESSAGE_REQUEST) ||
eventName.equalsIgnoreCase(MessagingConstants.SEND_PRIVATE_CHAT_MESSAGE_REQUEST)){
String meetingID = payloadObject.get("meeting_id").toString().replace("\"", "");
String requesterID = payloadObject.get("requester_id").toString().replace("\"", "");
//case getChatHistory
if(eventName.equalsIgnoreCase("get_chat_history")) {
String replyTo = meetingID + "/" + requesterID;
bbbGW.getChatHistory(meetingID, requesterID, replyTo);
}
else {
String chatType = messageObject.get("chat_type").toString().replace("\"", "");
String fromUserID = messageObject.get("from_userid").toString().replace("\"", "");
String fromUsername = messageObject.get("from_username").toString().replace("\"", "");
String fromColor = messageObject.get("from_color").toString().replace("\"", "");
String fromTime = messageObject.get("from_time").toString().replace("\"", "");
String fromTimezoneOffset = messageObject.get("from_tz_offset").toString().replace("\"", "");
String toUserID = messageObject.get("to_userid").toString().replace("\"", "");
String toUsername = messageObject.get("to_username").toString().replace("\"", "");
String tempChat = messageObject.get("message").toString();
String chatText = tempChat.substring(1, tempChat.length() - 1).replace("\\\"", "\"");
Map<String, String> map = new HashMap<String, String>();
map.put(ChatKeyUtil.CHAT_TYPE, chatType);
map.put(ChatKeyUtil.FROM_USERID, fromUserID);
map.put(ChatKeyUtil.FROM_USERNAME, fromUsername);
map.put(ChatKeyUtil.FROM_COLOR, fromColor);
map.put(ChatKeyUtil.FROM_TIME, fromTime);
map.put(ChatKeyUtil.FROM_TZ_OFFSET, fromTimezoneOffset);
map.put(ChatKeyUtil.TO_USERID, toUserID);
map.put(ChatKeyUtil.TO_USERNAME, toUsername);
map.put(ChatKeyUtil.MESSAGE, chatText);
if(eventName.equalsIgnoreCase(MessagingConstants.SEND_PUBLIC_CHAT_MESSAGE_REQUEST)) {
bbbGW.sendPublicMessage(meetingID, requesterID, map);
}
else if(eventName.equalsIgnoreCase(MessagingConstants.SEND_PRIVATE_CHAT_MESSAGE_REQUEST)) {
bbbGW.sendPrivateMessage(meetingID, requesterID, map);
}
}
}

View File

@ -1,59 +0,0 @@
package org.bigbluebutton.conference.service.messaging;
import java.util.HashMap;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
public class GetChatHistory implements IMessage {
public static final String GET_CHAT_HISTORY_REQUEST = "get_chat_history_request";
public static final String VERSION = "0.0.1";
public final String meetingId;
public final String replyTo;
public final String requesterId;
public GetChatHistory(String meetingId, String requesterId, String replyTo) {
this.meetingId = meetingId;
this.replyTo = replyTo;
this.requesterId = requesterId;
System.out.println("GetChatHistory constructor"+replyTo);
System.out.println("GetChatHistory requesterId"+requesterId);
}
public String toJson() {
HashMap<String, Object> payload = new HashMap<String, Object>();
payload.put(Constants.MEETING_ID, meetingId);
payload.put(Constants.REPLY_TO, replyTo);
payload.put(Constants.REQUESTER_ID, requesterId);
java.util.HashMap<String, Object> header = MessageBuilder.buildHeader(GET_CHAT_HISTORY_REQUEST, VERSION, null);
return MessageBuilder.buildJson(header, payload);
}
public static GetChatHistory fromJson(String message) {
JsonParser parser = new JsonParser();
JsonObject obj = (JsonObject) parser.parse(message);
if (obj.has("header") && obj.has("payload")) {
JsonObject header = (JsonObject) obj.get("header");
JsonObject payload = (JsonObject) obj.get("payload");
if (header.has("name")) {
String messageName = header.get("name").getAsString();
if (GET_CHAT_HISTORY_REQUEST.equals(messageName)) {
if (payload.has(Constants.MEETING_ID)
&& payload.has(Constants.REPLY_TO)
&& payload.has(Constants.REQUESTER_ID)) {
String meetingId = payload.get(Constants.MEETING_ID).getAsString();
String replyTo = payload.get(Constants.REPLY_TO).getAsString();
String requesterId = payload.get(Constants.REQUESTER_ID).getAsString();
return new GetChatHistory(meetingId, replyTo, requesterId);
}
}
}
}
return null;
}
}

View File

@ -1,97 +0,0 @@
package org.bigbluebutton.conference.service.messaging;
import java.util.HashMap;
import java.util.Map;
import org.bigbluebutton.conference.service.chat.ChatKeyUtil;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
public class SendPrivateChatMessage implements IMessage {
public static final String SEND_PRIVATE_CHAT_MESSAGE = "send_private_chat_message";
public static final String VERSION = "0.0.1";
public final String meetingId;
public final String requesterId;
public final Map<String, String> messageInfo;
public SendPrivateChatMessage(String meetingId, String requesterId,
Map<String, String> message) {
this.meetingId = meetingId;
this.requesterId = requesterId;
this.messageInfo = message;
}
public String toJson() {
HashMap<String, Object> payload = new HashMap<String, Object>();
Map<String, String> message = new HashMap<String, String>();
message.put(ChatKeyUtil.CHAT_TYPE, messageInfo.get(ChatKeyUtil.CHAT_TYPE));
message.put(ChatKeyUtil.MESSAGE, messageInfo.get(ChatKeyUtil.MESSAGE));
message.put(ChatKeyUtil.TO_USERNAME, messageInfo.get(ChatKeyUtil.TO_USERNAME));
message.put(ChatKeyUtil.FROM_TZ_OFFSET, messageInfo.get(ChatKeyUtil.FROM_TZ_OFFSET));
message.put(ChatKeyUtil.FROM_COLOR, messageInfo.get(ChatKeyUtil.FROM_COLOR));
message.put(ChatKeyUtil.TO_USERID, messageInfo.get(ChatKeyUtil.TO_USERID));
message.put(ChatKeyUtil.FROM_USERID, messageInfo.get(ChatKeyUtil.FROM_USERID));
message.put(ChatKeyUtil.FROM_TIME, messageInfo.get(ChatKeyUtil.FROM_TIME));
message.put(ChatKeyUtil.FROM_USERNAME, messageInfo.get(ChatKeyUtil.FROM_USERNAME));
payload.put(Constants.MESSAGE, message);
payload.put(Constants.MEETING_ID, meetingId);
java.util.HashMap<String, Object> header = MessageBuilder.buildHeader(SEND_PRIVATE_CHAT_MESSAGE, VERSION, null);
System.out.println("SendPrivateChatMessage toJson");
return MessageBuilder.buildJson(header, payload);
}
public static SendPrivateChatMessage fromJson(String message) {
JsonParser parser = new JsonParser();
JsonObject obj = (JsonObject) parser.parse(message);
if (obj.has("header") && obj.has("payload")) {
JsonObject header = (JsonObject) obj.get("header");
JsonObject payload = (JsonObject) obj.get("payload");
if (header.has("name")) {
String messageName = header.get("name").getAsString();
if (SEND_PRIVATE_CHAT_MESSAGE.equals(messageName)) {
if (payload.has(Constants.MEETING_ID)
&& payload.has(Constants.MESSAGE)) {
String meetingId = payload.get(Constants.MEETING_ID).getAsString();
JsonObject msgObj = (JsonObject) payload.get(Constants.MESSAGE).getAsJsonObject();
Map<String, String> messageInfo = new HashMap<String, String>();
if (msgObj.has(ChatKeyUtil.CHAT_TYPE)
&& msgObj.has(ChatKeyUtil.MESSAGE)
&& msgObj.has(ChatKeyUtil.TO_USERNAME)
&& msgObj.has(ChatKeyUtil.FROM_TZ_OFFSET)
&& msgObj.has(ChatKeyUtil.FROM_COLOR)
&& msgObj.has(ChatKeyUtil.TO_USERID)
&& msgObj.has(ChatKeyUtil.FROM_USERID)
&& msgObj.has(ChatKeyUtil.FROM_TIME)
&& msgObj.has(ChatKeyUtil.FROM_USERNAME)){
messageInfo.put(ChatKeyUtil.CHAT_TYPE, msgObj.get(ChatKeyUtil.CHAT_TYPE).getAsString());
messageInfo.put(ChatKeyUtil.MESSAGE, msgObj.get(ChatKeyUtil.MESSAGE).getAsString());
messageInfo.put(ChatKeyUtil.TO_USERNAME, msgObj.get(ChatKeyUtil.TO_USERNAME).getAsString());
messageInfo.put(ChatKeyUtil.FROM_TZ_OFFSET, msgObj.get(ChatKeyUtil.FROM_TZ_OFFSET).getAsString());
messageInfo.put(ChatKeyUtil.FROM_COLOR, msgObj.get(ChatKeyUtil.FROM_COLOR).getAsString());
messageInfo.put(ChatKeyUtil.TO_USERID, msgObj.get(ChatKeyUtil.TO_USERID).getAsString());
messageInfo.put(ChatKeyUtil.FROM_USERID, msgObj.get(ChatKeyUtil.FROM_USERID).getAsString());
messageInfo.put(ChatKeyUtil.FROM_TIME, msgObj.get(ChatKeyUtil.FROM_TIME).getAsString());
messageInfo.put(ChatKeyUtil.FROM_USERNAME, msgObj.get(ChatKeyUtil.FROM_USERNAME).getAsString());
String requesterId = messageInfo.get(ChatKeyUtil.FROM_USERID);
System.out.println("SendPrivateChatMessage fromJson");
return new SendPrivateChatMessage(meetingId, requesterId, messageInfo);
}
}
}
}
}
return null;
}
}

View File

@ -1,97 +0,0 @@
package org.bigbluebutton.conference.service.messaging;
import java.util.HashMap;
import java.util.Map;
import org.bigbluebutton.conference.service.chat.ChatKeyUtil;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
public class SendPublicChatMessage implements IMessage {
public static final String SEND_PUBLIC_CHAT_MESSAGE = "send_public_chat_message";
public static final String VERSION = "0.0.1";
public final String meetingId;
public final String requesterId;
public final Map<String, String> messageInfo;
public SendPublicChatMessage(String meetingId, String requesterId,
Map<String, String> message) {
this.meetingId = meetingId;
this.requesterId = requesterId;
this.messageInfo = message;
}
public String toJson() {
HashMap<String, Object> payload = new HashMap<String, Object>();
Map<String, String> message = new HashMap<String, String>();
message.put(ChatKeyUtil.CHAT_TYPE, messageInfo.get(ChatKeyUtil.CHAT_TYPE));
message.put(ChatKeyUtil.MESSAGE, messageInfo.get(ChatKeyUtil.MESSAGE));
message.put(ChatKeyUtil.TO_USERNAME, messageInfo.get(ChatKeyUtil.TO_USERNAME));
message.put(ChatKeyUtil.FROM_TZ_OFFSET, messageInfo.get(ChatKeyUtil.FROM_TZ_OFFSET));
message.put(ChatKeyUtil.FROM_COLOR, messageInfo.get(ChatKeyUtil.FROM_COLOR));
message.put(ChatKeyUtil.TO_USERID, messageInfo.get(ChatKeyUtil.TO_USERID));
message.put(ChatKeyUtil.FROM_USERID, messageInfo.get(ChatKeyUtil.FROM_USERID));
message.put(ChatKeyUtil.FROM_TIME, messageInfo.get(ChatKeyUtil.FROM_TIME));
message.put(ChatKeyUtil.FROM_USERNAME, messageInfo.get(ChatKeyUtil.FROM_USERNAME));
payload.put(Constants.MESSAGE, message);
payload.put(Constants.MEETING_ID, meetingId);
java.util.HashMap<String, Object> header = MessageBuilder.buildHeader(SEND_PUBLIC_CHAT_MESSAGE, VERSION, null);
System.out.println("sendPublicChatMessage toJson");
return MessageBuilder.buildJson(header, payload);
}
public static SendPublicChatMessage fromJson(String message) {
JsonParser parser = new JsonParser();
JsonObject obj = (JsonObject) parser.parse(message);
if (obj.has("header") && obj.has("payload")) {
JsonObject header = (JsonObject) obj.get("header");
JsonObject payload = (JsonObject) obj.get("payload");
if (header.has("name")) {
String messageName = header.get("name").getAsString();
if (SEND_PUBLIC_CHAT_MESSAGE.equals(messageName)) {
if (payload.has(Constants.MEETING_ID)
&& payload.has(Constants.MESSAGE)) {
String meetingId = payload.get(Constants.MEETING_ID).getAsString();
JsonObject msgObj = (JsonObject) payload.get(Constants.MESSAGE).getAsJsonObject();
Map<String, String> messageInfo = new HashMap<String, String>();
if (msgObj.has(ChatKeyUtil.CHAT_TYPE)
&& msgObj.has(ChatKeyUtil.MESSAGE)
&& msgObj.has(ChatKeyUtil.TO_USERNAME)
&& msgObj.has(ChatKeyUtil.FROM_TZ_OFFSET)
&& msgObj.has(ChatKeyUtil.FROM_COLOR)
&& msgObj.has(ChatKeyUtil.TO_USERID)
&& msgObj.has(ChatKeyUtil.FROM_USERID)
&& msgObj.has(ChatKeyUtil.FROM_TIME)
&& msgObj.has(ChatKeyUtil.FROM_USERNAME)){
messageInfo.put(ChatKeyUtil.CHAT_TYPE, msgObj.get(ChatKeyUtil.CHAT_TYPE).getAsString());
messageInfo.put(ChatKeyUtil.MESSAGE, msgObj.get(ChatKeyUtil.MESSAGE).getAsString());
messageInfo.put(ChatKeyUtil.TO_USERNAME, msgObj.get(ChatKeyUtil.TO_USERNAME).getAsString());
messageInfo.put(ChatKeyUtil.FROM_TZ_OFFSET, msgObj.get(ChatKeyUtil.FROM_TZ_OFFSET).getAsString());
messageInfo.put(ChatKeyUtil.FROM_COLOR, msgObj.get(ChatKeyUtil.FROM_COLOR).getAsString());
messageInfo.put(ChatKeyUtil.TO_USERID, msgObj.get(ChatKeyUtil.TO_USERID).getAsString());
messageInfo.put(ChatKeyUtil.FROM_USERID, msgObj.get(ChatKeyUtil.FROM_USERID).getAsString());
messageInfo.put(ChatKeyUtil.FROM_TIME, msgObj.get(ChatKeyUtil.FROM_TIME).getAsString());
messageInfo.put(ChatKeyUtil.FROM_USERNAME, msgObj.get(ChatKeyUtil.FROM_USERNAME).getAsString());
String requesterId = messageInfo.get(ChatKeyUtil.FROM_USERID);
System.out.println("sendPublicChatMessage fromJson");
return new SendPublicChatMessage(meetingId, requesterId, messageInfo);
}
}
}
}
}
return null;
}
}

View File

@ -2,16 +2,10 @@ package org.bigbluebutton.core.api;
import java.util.Map;
import org.bigbluebutton.conference.service.messaging.GetChatHistory;
import org.bigbluebutton.conference.service.messaging.MessagingConstants;
import org.bigbluebutton.conference.service.messaging.SendPublicChatMessage;
import org.bigbluebutton.conference.service.messaging.MessagingConstants;
import org.bigbluebutton.conference.service.messaging.ValidateAuthTokenMessage;
import org.bigbluebutton.conference.service.messaging.redis.MessageSender;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
public class Red5BBBInGw implements IBigBlueButtonInGW {
private MessageSender sender;
@ -444,21 +438,21 @@ public class Red5BBBInGw implements IBigBlueButtonInGW {
@Override
public void getChatHistory(String meetingID, String requesterID,
String replyTo) {
GetChatHistory msg = new GetChatHistory(meetingID, requesterID, replyTo);
sender.send(MessagingConstants.TO_CHAT_CHANNEL, msg.toJson());
// TODO Auto-generated method stub
}
@Override
public void sendPublicMessage(String meetingID, String requesterID,
Map<String, String> message) {
SendPublicChatMessage msg = new SendPublicChatMessage(meetingID, requesterID, message);
sender.send(MessagingConstants.TO_CHAT_CHANNEL, msg.toJson());
// TODO Auto-generated method stub
}
@Override
public void sendPrivateMessage(String meetingID, String requesterID,
Map<String, String> message) {
// TODO Auto-generated method stub
}