added gson and publish updates in bbb-web, missing receiving code in bbb-apps

This commit is contained in:
Marco Calderon 2011-06-14 01:43:55 +00:00
parent 2ac6aaa09a
commit e858828162
16 changed files with 175 additions and 83 deletions

View File

@ -118,6 +118,7 @@ dependencies {
// Freeswitch ESL Client
compile 'org/freeswitch:fs-esl-client:0.8.1@jar'
compile 'org.jboss.netty:netty:3.2.1.Final@jar'
compile 'com.google.code.gson:gson:1.7.1@jar'
}
test {

View File

@ -5,6 +5,8 @@ import java.util.HashMap;
import org.bigbluebutton.conference.RoomsManager;
import org.bigbluebutton.conference.service.presentation.ConversionUpdatesMessageListener;
import com.google.gson.Gson;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPubSub;
@ -17,13 +19,17 @@ public class RedisListener{
ConversionUpdatesMessageListener messageListener;
public RedisListener() {
super();
System.out.println("creating redislistener.java");
}
public void init(){
Jedis jedis = redisPool.getResource();
Jedis jedis = new Jedis("localhost");//redisPool.getResource();
//subscribe(jedis);
redisPool.returnResource(jedis);
//redisPool.returnResource(jedis);
System.out.println("setting redislistener.java");
subscribe(jedis);
}
public void subscribe(final Jedis jedis){
@ -67,10 +73,13 @@ public class RedisListener{
}
}
else if(channel.equalsIgnoreCase("bigbluebutton:meeting:presentation")){
String[] args=message.split(":");
//String[] args=message.split(":");
System.out.println("receiving Message "+message);
Gson gson=new Gson();
HashMap<String,Object> map=new HashMap<String, Object>();
map.put("code",args[0]);
HashMap<String,Object> map=gson.fromJson(message, HashMap.class);
/*map.put("code",args[0]);
map.put("presentationName",args[1]);
map.put("conference",args[2]);
@ -87,7 +96,7 @@ public class RedisListener{
}
else if(messageKey.equalsIgnoreCase(ConversionUpdatesMessageListener.CONVERSION_COMPLETED_KEY)){
map.put("slidesInfo", args[4]);
}
}*/
messageListener.handleReceivedMessage(map);
}

View File

@ -50,7 +50,7 @@ public class ConversionUpdatesProcessor {
try {
// Create a Runnable (Closures implements Runnable) to process the messages.
exec.execute(new Runnable() {
/*exec.execute(new Runnable() {
@SuppressWarnings("unchecked")
@Override
@ -66,7 +66,7 @@ public class ConversionUpdatesProcessor {
}
}
}
});
});*/
} catch (RejectedExecutionException e) {
if (!exec.isShutdown())

View File

@ -17,6 +17,31 @@
http://www.springframework.org/schema/integration/file/spring-integration-file-1.0.xsd
">
<!-- RECORDER AND MESSAGING -->
<bean id="recorderApplication" class="org.bigbluebutton.conference.service.recorder.RecorderApplication">
<property name="recorder"><ref local="redisRecorder" /> </property>
</bean>
<bean id="redisRecorder" class="org.bigbluebutton.conference.service.recorder.RedisDispatcher">
<property name="redisPool"><ref local="redisPool" /> </property>
</bean>
<bean id="redisListener" class="org.bigbluebutton.conference.service.messaging.RedisListener" init-method="init">
<property name="redisPool"><ref local="redisPool" /> </property>
<property name="roomsManager"> <ref local="roomsManager"/></property>
<property name="messageListener"> <ref local="messageListener"/></property>
</bean>
<bean id="redisPublisher" class="org.bigbluebutton.conference.service.messaging.RedisPublisher">
<property name="redisPool"><ref local="redisPool" /> </property>
</bean>
<bean id="redisPool" class="redis.clients.jedis.JedisPool">
<constructor-arg index="0" value="${redis.host}"/>
<constructor-arg index="1" value="${redis.port}"/>
</bean>
<bean id="roomsManager" class="org.bigbluebutton.conference.RoomsManager">
<property name="publisher" ref="redisPublisher"></property>
</bean>
@ -61,17 +86,17 @@
<property name="presentationApplication"> <ref local="presentationApplication"/></property>
</bean>
<!-- bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL">
<value>tcp://localhost:61616</value>
</property>
</bean-->
</bean>
<!-- bean id="destination" class="org.apache.activemq.command.ActiveMQQueue">
<bean id="destination" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg index="0">
<value>UpdatesQueue</value>
</constructor-arg>
</bean-->
</bean>
<bean id="conversionUpdatesProcessor" class="org.bigbluebutton.conference.service.presentation.ConversionUpdatesProcessor">
<property name="presentationApplication"> <ref local="presentationApplication"/></property>
@ -81,11 +106,11 @@
<property name="conversionUpdatesProcessor" ref="conversionUpdatesProcessor" />
</bean>
<!-- bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="connectionFactory"/>
<property name="destination" ref="destination"/>
<property name="messageListener" ref="messageListener" />
</bean-->
</bean>
<!-- END PRESENTATION -->
<!-- BEGIN CHAT -->
@ -121,30 +146,7 @@
<!-- END WHITEBOARD -->
<!-- RECORDER AND MESSAGING -->
<bean id="recorderApplication" class="org.bigbluebutton.conference.service.recorder.RecorderApplication">
<property name="recorder"><ref local="redisRecorder" /> </property>
</bean>
<bean id="redisRecorder" class="org.bigbluebutton.conference.service.recorder.RedisDispatcher">
<property name="redisPool"><ref local="redisPool" /> </property>
</bean>
<bean id="redisListener" class="org.bigbluebutton.conference.service.messaging.RedisListener" init-method="init">
<property name="redisPool"><ref local="redisPool" /> </property>
<property name="roomsManager"> <ref local="roomsManager"/></property>
<property name="messageListener"> <ref local="messageListener"/></property>
</bean>
<bean id="redisPublisher" class="org.bigbluebutton.conference.service.messaging.RedisPublisher">
<property name="redisPool"><ref local="redisPool" /> </property>
</bean>
<bean id="redisPool" class="redis.clients.jedis.JedisPool">
<constructor-arg index="0" value="${redis.host}"/>
<constructor-arg index="1" value="${redis.port}"/>
</bean>
<!-- END RECORDER AND MESSAGING -->

View File

@ -69,7 +69,7 @@ defaultMaxUsers=20
#----------------------------------------------------
# This URL is where the BBB client is accessible. When a user sucessfully
# enters a name and password, she is redirected here to load the client.
bigbluebutton.web.serverURL=http://192.168.1.38
bigbluebutton.web.serverURL=http://192.168.1.35
#----------------------------------------------------
# Assign URL where the logged-out participant will be redirected after sign-out.

View File

@ -17,7 +17,8 @@
<integration:filter ref="supportedDocumentFilter" method="isSupported" input-channel="convertChannel"
output-channel="docRouterChannel"/>
<bean id="supportedDocumentFilter" class="org.bigbluebutton.presentation.SupportedDocumentFilter">
<property name="conversionProgressNotifier" ref="conversionProgressNotifier"/>
<!-- property name="conversionProgressNotifier" ref="conversionProgressNotifier"/ -->
<property name="messagingService" ref="messagingService"></property>
</bean>
<integration:channel id="docRouterChannel"/>
@ -27,8 +28,8 @@
<integration:channel id="officeFileChannel"/>
<integration:channel id="pdfFileChannel"/>
<integration:channel id="imageFileChannel"/>
<integration:channel id="conversionProgressChannel"/>
<integration:gateway id="conversionProgressNotifier" service-interface="org.bigbluebutton.presentation.ConversionProgressNotifier"/>
<!-- integration:channel id="conversionProgressChannel"/>
<integration:gateway id="conversionProgressNotifier" service-interface="org.bigbluebutton.presentation.ConversionProgressNotifier"/-->
<integration:service-activator input-channel="officeFileChannel" output-channel="officeToPdfConvertResultChannel"
ref="officeToPdfConversionService" method="convertOfficeToPdf"/>
@ -38,7 +39,8 @@
<integration:filter ref="officeToPdfConversionSuccessFilter" method="didConversionSucceed" input-channel="officeToPdfConvertResultChannel"
output-channel="convertChannel"/>
<bean id="officeToPdfConversionSuccessFilter" class="org.bigbluebutton.presentation.OfficeToPdfConversionSuccessFilter">
<property name="conversionProgressNotifier" ref="conversionProgressNotifier"/>
<!-- property name="conversionProgressNotifier" ref="conversionProgressNotifier"/-->
<property name="messagingService" ref="messagingService"></property>
</bean>
<integration:service-activator input-channel="pdfFileChannel" ref="pdfToSwfSlidesGenerationService" method="generateSlides"/>
@ -46,8 +48,8 @@
<integration:service-activator input-channel="imageFileChannel" ref="imageToSwfSlidesGenerationService" method="generateSlides"/>
<jms:outbound-channel-adapter id="jmsOut" destination-name="UpdatesQueue" channel="conversionProgressChannel"/>
<!-- jms:outbound-channel-adapter id="jmsOut" destination-name="UpdatesQueue" channel="conversionProgressChannel"/-->
<bean id="pageExtractor" class="org.bigbluebutton.presentation.imp.GhostscriptPageExtractor">
<property name="ghostscriptExec" value="${ghostScriptExec}"/>
<property name="noPdfMarkWorkaround" value="${noPdfMarkWorkaround}"/>
@ -112,7 +114,8 @@
</bean>
<bean id="swfSlidesGenerationProgressNotifier" class="org.bigbluebutton.presentation.imp.SwfSlidesGenerationProgressNotifier">
<property name="conversionProgressNotifier" ref="conversionProgressNotifier"/>
<!-- property name="conversionProgressNotifier" ref="conversionProgressNotifier"/-->
<property name="messagingService" ref="messagingService"></property>
<property name="generatedSlidesInfoHelper" ref="generatedSlidesInfoHelper"/>
</bean>

View File

@ -50,4 +50,6 @@ public class GeneratedSlidesInfoHelperImp implements GeneratedSlidesInfoHelper {
return writer.toString()
}
}

View File

@ -154,7 +154,17 @@ public class MeetingServiceImp implements MeetingService {
m.userLeft(userId);
log.debug("Removing user...");
}
}
}
@Override
public void updatedStatus(String meetingId, String userId, String status, String value) {
Meeting m = getMeeting(meetingId);
if (m != null) {
User user=m.getUserById(userId);
user.setStatus(status, value);
log.debug("Setting status...");
}
}
}
}

View File

@ -170,6 +170,10 @@ public class Meeting {
users.remove(userid);
}
public User getUserById(String id){
return this.users.get(id);
}
public int getNumUsers(){
return this.users.size();
}

View File

@ -1,14 +1,19 @@
package org.bigbluebutton.api.domain;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class User {
private String userid;
private String fullname;
private String role;
private Map<String,String> status;
public User(String userid, String fullname, String role) {
this.userid = userid;
this.fullname = fullname;
this.role = role;
this.status = new ConcurrentHashMap<String, String>();
}
public String getUserid() {
@ -34,5 +39,13 @@ public class User {
return this.role.equalsIgnoreCase("MODERATOR");
}
public void setStatus(String key, String value){
this.status.put(key, value);
}
public void removeStatus(String key){
this.status.remove(key);
}
public Map<String,String> getStatus(){
return this.status;
}
}

View File

@ -5,4 +5,5 @@ public interface MessageListener {
void meetingEnded(String meetingId);
void userJoined(String meetingId, String userId, String name, String role);
void userLeft(String meetingId, String userId);
void updatedStatus(String meetingId, String userId, String status, String value);
}

View File

@ -2,13 +2,18 @@ package org.bigbluebutton.api.messaging;
import java.util.Map;
public interface MessagingService {
void start();
void stop();
void recordMeetingInfo(String meetingId, Map<String, String> info);
void recordMeetingMetadata(String meetingId, Map<String, String> metadata);
void endMeeting(String meetingId);
void send(String channel, String message);
void addListener(MessageListener listener);
void removeListener(MessageListener listener);
public abstract class MessagingService {
//patterns
public static String MEETING_EVENTS="bigbluebutton:meeting:*";
public static String PRESENTATION_CHANNEL="bigbluebutton:meeting:presentation";
public void start(){}
public void stop(){}
public void recordMeetingInfo(String meetingId, Map<String, String> info){}
public void recordMeetingMetadata(String meetingId, Map<String, String> metadata){}
public void endMeeting(String meetingId){}
public void send(String channel, String message){}
public void addListener(MessageListener listener){}
public void removeListener(MessageListener listener){}
}

View File

@ -9,11 +9,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisException;
import redis.clients.jedis.exceptions.JedisException;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPubSub;
public class RedisMessagingService implements MessagingService {
public class RedisMessagingService extends MessagingService {
private static Logger log = LoggerFactory.getLogger(RedisMessagingService.class);
private JedisPool redisPool;
@ -83,11 +83,12 @@ public class RedisMessagingService implements MessagingService {
@Override
public void start() {
log.debug("Starting redis pubsub...");
final Jedis jedis=redisPool.getResource();
//final Jedis jedis=redisPool.getResource();
final Jedis jedis= new Jedis("localhost");
try {
pubsubListener = new Runnable() {
public void run() {
jedis.psubscribe(new PubSubListener(), "bigbluebutton:meeting:*");
jedis.psubscribe(new PubSubListener(), MEETING_EVENTS);
}
};
exec.execute(pubsubListener);
@ -95,7 +96,7 @@ public class RedisMessagingService implements MessagingService {
} catch (JedisException e) {
log.error("Cannot subscribe to the redis channel");
}finally{
redisPool.returnResource(jedis);
//redisPool.returnResource(jedis);
}
}
@ -123,7 +124,6 @@ public class RedisMessagingService implements MessagingService {
**/
private class PubSubListener extends JedisPubSub {
private final String PATTERN_MEETING="bigbluebutton:meeting:*";
private final String CHANNEL_STATE="bigbluebutton:meeting:state";
private final String CHANNEL_PARTICIPANTS="bigbluebutton:meeting:participants";
@ -178,8 +178,10 @@ public class RedisMessagingService implements MessagingService {
String userid=args[2];
String status=args[3];
String value=args[4];
//missing method...
//dynamicConferenceService.participantsUpdatedStatus(roomname, userid, status, value);
for (MessageListener listener : listeners) {
listener.updatedStatus(meetingId, userid, status, value);
}
}
else if(action.equalsIgnoreCase("left")){
String userid=args[2];

View File

@ -25,12 +25,16 @@ package org.bigbluebutton.presentation;
import java.util.HashMap;
import java.util.Map;
import org.bigbluebutton.api.messaging.MessagingService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
public class OfficeToPdfConversionSuccessFilter {
private static Logger log = LoggerFactory.getLogger(OfficeToPdfConversionSuccessFilter.class);
private ConversionProgressNotifier notifier;
//private ConversionProgressNotifier notifier;
private MessagingService messagingService;
public boolean didConversionSucceed(UploadedPresentation pres) {
notifyProgressListener(pres);
@ -58,14 +62,22 @@ public class OfficeToPdfConversionSuccessFilter {
}
private void sendNotification(Map<String, Object> msg) {
if (notifier != null) {
notifier.sendConversionProgress(msg);
//if (notifier != null) {
//notifier.sendConversionProgress(msg);
if(messagingService !=null){
Gson gson= new Gson();
String updateMsg=gson.toJson(msg);
log.debug("sending: "+updateMsg);
messagingService.send(MessagingService.PRESENTATION_CHANNEL, updateMsg);
} else {
log.warn("ConversionProgressNotifier has not been set!.");
}
}
public void setConversionProgressNotifier(ConversionProgressNotifier notifier) {
this.notifier = notifier;
//public void setConversionProgressNotifier(ConversionProgressNotifier notifier) {
//this.notifier = notifier;
//}
public void setMessagingService(MessagingService messagingService){
this.messagingService = messagingService;
}
}

View File

@ -23,13 +23,18 @@
package org.bigbluebutton.presentation;
import java.io.File;
import org.bigbluebutton.api.messaging.MessagingService;
import org.bigbluebutton.presentation.ConversionUpdateMessage.MessageBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
public class SupportedDocumentFilter {
private static Logger log = LoggerFactory.getLogger(SupportedDocumentFilter.class);
private ConversionProgressNotifier notifier;
//private ConversionProgressNotifier notifier;
private MessagingService messagingService;
public boolean isSupported(UploadedPresentation pres) {
File presentationFile = pres.getUploadedFile();
@ -55,14 +60,23 @@ public class SupportedDocumentFilter {
builder.messageKey(ConversionMessageConstants.UNSUPPORTED_DOCUMENT_KEY);
}
if (notifier != null) {
notifier.sendConversionProgress(builder.build().getMessage());
//if (notifier != null) {
//notifier.sendConversionProgress(builder.build().getMessage());
if(messagingService !=null){
Gson gson= new Gson();
String updateMsg=gson.toJson(builder.build().getMessage());
log.debug("sending: "+updateMsg);
messagingService.send(MessagingService.PRESENTATION_CHANNEL, updateMsg);
} else {
log.warn("ConversionProgressNotifier has not been set!");
}
}
public void setConversionProgressNotifier(ConversionProgressNotifier notifier) {
this.notifier = notifier;
public void setMessagingService(MessagingService messagingService) {
this.messagingService = messagingService;
}
//public void setConversionProgressNotifier(ConversionProgressNotifier notifier) {
//this.notifier = notifier;
//}
}

View File

@ -24,6 +24,8 @@ package org.bigbluebutton.presentation.imp;
import java.util.Map;
import org.apache.commons.lang.StringEscapeUtils;
import org.bigbluebutton.api.messaging.MessagingService;
import org.bigbluebutton.presentation.ConversionMessageConstants;
import org.bigbluebutton.presentation.ConversionProgressNotifier;
import org.bigbluebutton.presentation.ConversionUpdateMessage;
@ -33,15 +35,24 @@ import org.bigbluebutton.presentation.ConversionUpdateMessage.MessageBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
public class SwfSlidesGenerationProgressNotifier {
private static Logger log = LoggerFactory.getLogger(SwfSlidesGenerationProgressNotifier.class);
private ConversionProgressNotifier notifier;
//private ConversionProgressNotifier notifier;
private MessagingService messagingService;
private GeneratedSlidesInfoHelper generatedSlidesInfoHelper;
private void notifyProgressListener(Map<String, Object> msg) {
if (notifier != null) {
notifier.sendConversionProgress(msg);
//if (notifier != null) {
//notifier.sendConversionProgress(msg);
if(messagingService !=null){
Gson gson= new Gson();
String updateMsg=gson.toJson(msg);
log.debug("sending: "+updateMsg);
messagingService.send(MessagingService.PRESENTATION_CHANNEL, updateMsg);
} else {
log.warn("ConversionProgressNotifier has not been set");
}
@ -72,17 +83,20 @@ public class SwfSlidesGenerationProgressNotifier {
}
String xml = generatedSlidesInfoHelper.generateUploadedPresentationInfo(pres);
String escape_xml=StringEscapeUtils.escapeXml(xml);
MessageBuilder builder = new ConversionUpdateMessage.MessageBuilder(pres);
builder.messageKey(ConversionMessageConstants.CONVERSION_COMPLETED_KEY);
builder.slidesInfo(xml);
builder.slidesInfo(escape_xml);
notifyProgressListener(builder.build().getMessage());
}
public void setConversionProgressNotifier(ConversionProgressNotifier notifier) {
this.notifier = notifier;
}
//public void setConversionProgressNotifier(ConversionProgressNotifier notifier) {
//this.notifier = notifier;
//}
public void setMessagingService(MessagingService messagingService) {
this.messagingService = messagingService;
}
public void setGeneratedSlidesInfoHelper(GeneratedSlidesInfoHelper helper) {
generatedSlidesInfoHelper = helper;
}