- wire up new message path

This commit is contained in:
Richard Alam 2017-07-03 07:44:13 -07:00
parent 2e0f6d8610
commit 8ca0d6c9fe
41 changed files with 2232 additions and 1980 deletions

View File

@ -9,12 +9,25 @@ import org.bigbluebutton.common2.domain.DefaultProps
body: CreateMeetingReqMsgBody) extends BbbCoreMsg
case class CreateMeetingReqMsgBody(props: DefaultProps)
object DestroyMeetingSysCmdMsg { val NAME = "DestroyMeetingSysCmdMsg" }
case class DestroyMeetingSysCmdMsg(header: BbbCoreBaseHeader,
body: DestroyMeetingSysCmdMsgBody) extends BbbCoreMsg
case class DestroyMeetingSysCmdMsgBody(meetingId: String)
object EndMeetingSysCmdMsg { val NAME = "DestroyMeetingReqMsg" }
case class EndMeetingSysCmdMsg(header: BbbCoreBaseHeader,
body: EndMeetingSysCmdMsgBody) extends BbbCoreMsg
case class EndMeetingSysCmdMsgBody(meetingId: String)
object GetAllMeetingsReqMsg { val NAME = "GetAllMeetingsReqMsg" }
case class GetAllMeetingsReqMsg(header: BbbCoreBaseHeader,
body: GetAllMeetingsReqMsgBody) extends BbbCoreMsg
case class GetAllMeetingsReqMsgBody(requesterId: String)
object PubSubPingSysReqMsg { val NAME = "PubSubPingSysReqMsg" }
case class PubSubPingSysReqMsg(header: BbbCoreBaseHeader,
body: PubSubPingSysReqMsgBody) extends BbbCoreMsg
case class PubSubPingSysReqMsgBody(system: String, timestamp: Long)
/** Response Messages **/
object MeetingCreatedEvtMsg { val NAME = "MeetingCreatedEvtMsg"}
@ -22,12 +35,27 @@ import org.bigbluebutton.common2.domain.DefaultProps
body: MeetingCreatedEvtBody) extends BbbCoreMsg
case class MeetingCreatedEvtBody(props: DefaultProps)
object MeetingEndedEvtMsg { val NAME = "MeetingEndedEvtMsg"}
case class MeetingEndedEvtMsg(header: BbbCoreBaseHeader,
body: MeetingEndedEvtMsgBody) extends BbbCoreMsg
case class MeetingEndedEvtMsgBody(meetingId: String)
object SyncGetMeetingInfoRespMsg { val NAME = "SyncGetMeetingInfoRespMsg"}
object MeetingDestroyedEvtMsg { val NAME = "MeetingDestroyedEvtMsg"}
case class MeetingDestroyedEvtMsg(header: BbbCoreBaseHeader,
body: MeetingDestroyedEvtMsgBody) extends BbbCoreMsg
case class MeetingDestroyedEvtMsgBody(meetingId: String)
object SyncGetMeetingInfoRespMsg { val NAME = "SyncGetMeetingInfoRespMsg"}
case class SyncGetMeetingInfoRespMsg(header: BbbCoreBaseHeader,
body: SyncGetMeetingInfoRespMsgBody) extends BbbCoreMsg
case class SyncGetMeetingInfoRespMsgBody(props: DefaultProps)
object PubSubPongSysRespMsg { val NAME = "PubSubPongSysRespMsg" }
case class PubSubPongSysRespMsg(header: BbbCoreBaseHeader,
body: PubSubPongSysRespMsgBody) extends BbbCoreMsg
case class PubSubPongSysRespMsgBody(system: String, timestamp: Long)
/** System Messages **/
case class AkkaAppsCheckAliveReqBody(timestamp: Long)

View File

@ -1,5 +1,7 @@
package org.bigbluebutton.api;
import org.bigbluebutton.api.messaging.messages.IMessage;
public interface IReceivedOldMessageHandler {
void handleMessage(String pattern, String channel, String message);
void handleMessage(IMessage msg);
}

View File

@ -1,20 +1,19 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* <p>
* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below).
*
* <p>
* 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
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
*
* <p>
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* <p>
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
*/
package org.bigbluebutton.api;
@ -42,6 +41,9 @@ import org.bigbluebutton.api.domain.*;
import org.bigbluebutton.api.messaging.MessageListener;
import org.bigbluebutton.api.messaging.MessagingConstants;
import org.bigbluebutton.api.messaging.MessagingService;
import org.bigbluebutton.api.messaging.RedisStorageService;
import org.bigbluebutton.api.messaging.converters.messages.DestroyMeetingMessage;
import org.bigbluebutton.api.messaging.converters.messages.EndMeetingMessage;
import org.bigbluebutton.api.messaging.messages.CreateBreakoutRoom;
import org.bigbluebutton.api.messaging.messages.CreateMeeting;
import org.bigbluebutton.api.messaging.messages.EndBreakoutRoom;
@ -62,6 +64,8 @@ import org.bigbluebutton.api.messaging.messages.UserStatusChanged;
import org.bigbluebutton.api.messaging.messages.UserUnsharedWebcam;
import org.bigbluebutton.api.pub.IPublisherService;
import org.bigbluebutton.api2.IBbbWebApiGWApp;
import org.bigbluebutton.common.messages.Constants;
import org.bigbluebutton.common.messages.SendStunTurnInfoReplyMessage;
import org.bigbluebutton.presentation.PresentationUrlDownloadService;
import org.bigbluebutton.api.messaging.messages.StunTurnInfoRequested;
import org.bigbluebutton.web.services.RegisteredUserCleanupTimerTask;
@ -79,21 +83,19 @@ public class MeetingService implements MessageListener {
private BlockingQueue<IMessage> receivedMessages = new LinkedBlockingQueue<IMessage>();
private volatile boolean processMessage = false;
private final Executor msgProcessorExec = Executors
.newSingleThreadExecutor();
private final Executor msgProcessorExec = Executors.newSingleThreadExecutor();
private final Executor runExec = Executors.newSingleThreadExecutor();
/**
* http://ria101.wordpress.com/2011/12/12/concurrenthashmap-avoid-a-common-
* misuse/
* http://ria101.wordpress.com/2011/12/12/concurrenthashmap-avoid-a-common-misuse/
*/
private final ConcurrentMap<String, Meeting> meetings;
private final ConcurrentMap<String, UserSession> sessions;
private RecordingService recordingService;
private MessagingService messagingService;
private RegisteredUserCleanupTimerTask registeredUserCleaner;
private StunTurnService stunTurnService;
private RedisStorageService storeService;
private ParamsProcessorUtil paramsProcessorUtil;
private PresentationUrlDownloadService presDownloadService;
@ -133,15 +135,13 @@ public class MeetingService implements MessageListener {
* Remove registered users who did not successfully joined the meeting.
*/
public void purgeRegisteredUsers() {
for (AbstractMap.Entry<String, Meeting> entry : this.meetings
.entrySet()) {
for (AbstractMap.Entry<String, Meeting> entry : this.meetings.entrySet()) {
Long now = System.nanoTime();
Meeting meeting = entry.getValue();
ConcurrentMap<String, User> users = meeting.getUsersMap();
for (AbstractMap.Entry<String, Long> registeredUser : meeting
.getRegisteredUsers().entrySet()) {
for (AbstractMap.Entry<String, Long> registeredUser : meeting.getRegisteredUsers().entrySet()) {
String registeredUserID = registeredUser.getKey();
Long registeredUserDate = registeredUser.getValue();
@ -181,8 +181,7 @@ public class MeetingService implements MessageListener {
}
private void removeUserSessions(String meetingId) {
Iterator<Map.Entry<String, UserSession>> iterator = sessions.entrySet()
.iterator();
Iterator<Map.Entry<String, UserSession>> iterator = sessions.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, UserSession> entry = iterator.next();
UserSession userSession = entry.getValue();
@ -193,17 +192,17 @@ public class MeetingService implements MessageListener {
}
}
private void destroyMeeting(String meetingID) {
messagingService.destroyMeeting(meetingID);
private void destroyMeeting(String meetingId) {
gw.destroyMeeting(new DestroyMeetingMessage(meetingId));
}
public Collection<Meeting> getMeetings() {
return meetings.isEmpty() ? Collections.<Meeting> emptySet()
return meetings.isEmpty() ? Collections.<Meeting>emptySet()
: Collections.unmodifiableCollection(meetings.values());
}
public Collection<UserSession> getSessions() {
return sessions.isEmpty() ? Collections.<UserSession> emptySet()
return sessions.isEmpty() ? Collections.<UserSession>emptySet()
: Collections.unmodifiableCollection(sessions.values());
}
@ -220,11 +219,11 @@ public class MeetingService implements MessageListener {
}
private void handleCreateMeeting(Meeting m) {
if (m.isBreakout()){
if (m.isBreakout()) {
Meeting parent = meetings.get(m.getParentMeetingId());
parent.addBreakoutRoom(m.getExternalId());
if (parent.isRecord()) {
messagingService.addBreakoutRoom(parent.getInternalId(), m.getInternalId());
storeService.addBreakoutRoom(parent.getInternalId(), m.getInternalId());
}
}
@ -236,21 +235,21 @@ public class MeetingService implements MessageListener {
metadata.put("meetingName", m.getName());
metadata.put("isBreakout", m.isBreakout().toString());
messagingService.recordMeetingInfo(m.getInternalId(), metadata);
storeService.recordMeetingInfo(m.getInternalId(), metadata);
if (m.isBreakout()) {
Map<String, String> breakoutMetadata = new TreeMap<String, String>();
breakoutMetadata.put("meetingId", m.getExternalId());
breakoutMetadata.put("sequence", m.getSequence().toString());
breakoutMetadata.put("parentMeetingId", m.getParentMeetingId());
messagingService.recordBreakoutInfo(m.getInternalId(), breakoutMetadata);
storeService.recordBreakoutInfo(m.getInternalId(), breakoutMetadata);
}
}
Map<String, Object> logData = new HashMap<String, Object>();
logData.put("meetingId", m.getInternalId());
logData.put("externalMeetingId", m.getExternalId());
if (m.isBreakout()){
if (m.isBreakout()) {
logData.put("sequence", m.getSequence());
logData.put("parentMeetingId", m.getParentMeetingId());
}
@ -266,15 +265,6 @@ public class MeetingService implements MessageListener {
log.info("Create meeting: data={}", logStr);
messagingService.createMeeting(m.getInternalId(), m.getExternalId(),
m.getParentMeetingId(), m.getName(), m.isRecord(),
m.getTelVoice(), m.getDuration(), m.getAutoStartRecording(),
m.getAllowStartStopRecording(), m.getWebcamsOnlyForModerator(),
m.getModeratorPassword(), m.getViewerPassword(),
m.getCreateTime(), formatPrettyDate(m.getCreateTime()),
m.isBreakout(), m.getSequence(), m.getMetadata(), m.getGuestPolicy());
gw.createMeeting(m.getInternalId(), m.getExternalId(),
m.getParentMeetingId(), m.getName(), m.isRecord(),
m.getTelVoice(), m.getDuration(), m.getAutoStartRecording(),
@ -295,7 +285,7 @@ public class MeetingService implements MessageListener {
}
private void processRegisterUser(RegisterUser message) {
messagingService.registerUser(message.meetingID,
gw.registerUser(message.meetingID,
message.internalUserId, message.fullname, message.role,
message.externUserID, message.authToken, message.avatarURL, message.guest, message.authed);
@ -317,7 +307,7 @@ public class MeetingService implements MessageListener {
public Collection<Meeting> getMeetingsWithId(String meetingId) {
if (meetingId == null)
return Collections.<Meeting> emptySet();
return Collections.<Meeting>emptySet();
Collection<Meeting> m = new HashSet<Meeting>();
@ -366,7 +356,6 @@ public class MeetingService implements MessageListener {
}
public Map<String, Recording> reorderRecordings(List<Recording> olds) {
Map<String, Recording> map = new HashMap<String, Recording>();
for (Recording r : olds) {
@ -471,12 +460,10 @@ public class MeetingService implements MessageListener {
/*
* Collection<Meeting> confs = meetings.values(); for (Meeting c :
* confs) { if (voiceBridge == c.getVoiceBridge()) { return true; } }
*/return false;
*/
return false;
}
public void send(String channel, String message) {
messagingService.send(channel, message);
}
public void endMeeting(String meetingId) {
handle(new EndMeeting(meetingId));
@ -497,11 +484,9 @@ public class MeetingService implements MessageListener {
params.put("voiceBridge", message.voiceConfId);
params.put("duration", message.durationInMinutes.toString());
params.put("record", message.record.toString());
params.put("welcome", getMeeting(message.parentMeetingId)
.getWelcomeMessageTemplate());
params.put("welcome", getMeeting(message.parentMeetingId).getWelcomeMessageTemplate());
Map<String, String> parentMeetingMetadata = parentMeeting
.getMetadata();
Map<String, String> parentMeetingMetadata = parentMeeting.getMetadata();
String metaPrefix = "meta_";
for (String key : parentMeetingMetadata.keySet()) {
@ -529,7 +514,7 @@ public class MeetingService implements MessageListener {
}
private void processEndMeeting(EndMeeting message) {
messagingService.endMeeting(message.meetingId);
gw.endMeeting(new EndMeetingMessage(message.meetingId));
}
private void processRemoveEndedMeeting(MeetingEnded message) {
@ -759,16 +744,42 @@ public class MeetingService implements MessageListener {
for (StunServer s : stuns) {
log.info("a stun: " + s.url);
}
Set<TurnEntry> turns = stunTurnService
.getStunAndTurnServersFor(message.internalUserId);
log.info("\nhere are the (" + turns.size()
+ ") turns for internalUserId:" + message.internalUserId);
Set<TurnEntry> turns = stunTurnService.getStunAndTurnServersFor(message.internalUserId);
log.info("\nhere are the (" + turns.size() + ") turns for internalUserId:" + message.internalUserId);
for (TurnEntry t : turns) {
log.info("a org.bigbluebutton.web.services.turn: " + t.url + "username/pass=" + t.username + '/'
+ t.password);
}
messagingService.sendStunTurnInfo(message.meetingId,
message.internalUserId, stuns, turns);
ArrayList<String> stunsArrayList = new ArrayList<String>();
Iterator<StunServer> stunsIter = stuns.iterator();
while (stunsIter.hasNext()) {
StunServer aStun = (StunServer) stunsIter.next();
if (aStun != null) {
stunsArrayList.add(aStun.url);
}
}
ArrayList<Map<String, Object>> turnsArrayList = new ArrayList<Map<String, Object>>();
Iterator<TurnEntry> turnsIter = turns.iterator();
while (turnsIter.hasNext()) {
TurnEntry te = (TurnEntry) turnsIter.next();
if (null != te) {
Map<String, Object> map = new HashMap<String, Object>();
map.put(Constants.USERNAME, te.username);
map.put(Constants.URL, te.url);
map.put(Constants.TTL, te.ttl);
map.put(Constants.PASSWORD, te.password);
turnsArrayList.add(map);
}
}
SendStunTurnInfoReplyMessage msg = new SendStunTurnInfoReplyMessage(message.meetingId,
message.internalUserId,stunsArrayList, turnsArrayList);
gw.sendStunTurnInfoReply(msg);
}
public void userJoinedVoice(UserJoinedVoice message) {
@ -835,7 +846,7 @@ public class MeetingService implements MessageListener {
Meeting m = getMeeting(message.meetingId);
if (m != null) {
User user = m.getUserById(message.userId);
if(user != null){
if (user != null) {
user.setRole(message.role);
log.debug("Setting new role in meeting " + message.meetingId + " for participant:" + user.getFullname());
return;
@ -862,7 +873,7 @@ public class MeetingService implements MessageListener {
} else if (message instanceof UserStatusChanged) {
updatedStatus((UserStatusChanged) message);
} else if (message instanceof UserRoleChanged) {
userRoleChanged((UserRoleChanged)message);
userRoleChanged((UserRoleChanged) message);
} else if (message instanceof UserJoinedVoice) {
userJoinedVoice((UserJoinedVoice) message);
} else if (message instanceof UserLeftVoice) {
@ -928,8 +939,8 @@ public class MeetingService implements MessageListener {
recordingService = s;
}
public void setMessagingService(MessagingService mess) {
messagingService = mess;
public void setRedisStorageService(RedisStorageService mess) {
storeService = mess;
}
public void setGw(IBbbWebApiGWApp gw) {

View File

@ -42,35 +42,17 @@ public class MeetingMessageHandler implements MessageHandler {
this.listeners = listeners;
}
public void handleMessage(String pattern, String channel, String message) {
JsonParser parser = new JsonParser();
JsonObject obj = (JsonObject) parser.parse(message);
if (channel.equalsIgnoreCase(MessagingConstants.FROM_MEETING_CHANNEL)) {
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(MessagingConstants.MEETING_STARTED_EVENT.equalsIgnoreCase(messageName)) {
String meetingId = payload.get("meeting_id").getAsString();
public void handleMessage(IMessage message) {
/*
for (MessageListener listener : listeners) {
listener.handle(new MeetingStarted(meetingId));
}
} else if(MessagingConstants.MEETING_ENDED_EVENT.equalsIgnoreCase(messageName)) {
String meetingId = payload.get("meeting_id").getAsString();
for (MessageListener listener : listeners) {
listener.handle(new MeetingEnded(meetingId));
}
} else if (MessagingConstants.MEETING_DESTROYED_EVENT.equalsIgnoreCase(messageName)) {
String meetingId = payload.get("meeting_id").getAsString();
log.info("Received a meeting destroyed message for meeting id=[{}]", meetingId);
for (MessageListener listener : listeners) {
listener.handle(new MeetingDestroyed(meetingId));
}
} else if (CreateBreakoutRoomRequest.NAME.equals(messageName)) {
CreateBreakoutRoomRequest msg = new Gson().fromJson(message, CreateBreakoutRoomRequest.class);
for (MessageListener listener : listeners) {
listener.handle(new CreateBreakoutRoom(
msg.payload.breakoutMeetingId,
@ -87,22 +69,9 @@ public class MeetingMessageHandler implements MessageHandler {
)
);
}
}
else if (EndBreakoutRoomRequest.NAME.equals(messageName)) {
EndBreakoutRoomRequest msg = new Gson().fromJson(message, EndBreakoutRoomRequest.class);
log.info("Received end breakout room request message for breakout meeting id=[{}]", msg.payload.meetingId);
for (MessageListener listener : listeners) {
listener.handle(new EndBreakoutRoom(msg.payload.meetingId));
}
}
}
}
} else if (channel.equalsIgnoreCase(MessagingConstants.FROM_SYSTEM_CHANNEL)) {
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();
IMessage rxMsg = null;
if (PubSubPongMessage.PUBSUB_PONG.equals(messageName)) {
IBigBlueButtonMessage msg = decoder.decodeMessage(message);
@ -116,93 +85,37 @@ public class MeetingMessageHandler implements MessageHandler {
listener.handle(rxMsg);
}
}
}
}
} else if (channel.equalsIgnoreCase(MessagingConstants.FROM_USERS_CHANNEL)) {
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 (MessagingConstants.USER_JOINED_EVENT.equalsIgnoreCase(messageName)) {
String meetingId = payload.get("meeting_id").getAsString();
JsonObject user = (JsonObject) payload.get("user");
String userid = user.get("userid").getAsString();
String externuserid = user.get("extern_userid").getAsString();
String username = user.get("name").getAsString();
String role = user.get("role").getAsString();
String avatarURL = user.get("avatarURL").getAsString();
Boolean guest = user.get("guest").getAsBoolean();
Boolean waitingForAcceptance = user.get("waiting_for_acceptance").getAsBoolean();
for (MessageListener listener : listeners) {
listener.handle(new UserJoined(meetingId, userid, externuserid, username, role, avatarURL, guest, waitingForAcceptance));
}
} else if(MessagingConstants.USER_STATUS_CHANGE_EVENT.equalsIgnoreCase(messageName)) {
String meetingId = payload.get("meeting_id").getAsString();
String userid = payload.get("userid").getAsString();
String status = payload.get("status").getAsString();
String value = payload.get("value").getAsString();
for (MessageListener listener : listeners) {
listener.handle(new UserStatusChanged(meetingId, userid, status, value));
}
} else if (MessagingConstants.USER_LEFT_EVENT.equalsIgnoreCase(messageName)) {
String meetingId = payload.get("meeting_id").getAsString();
JsonObject user = (JsonObject) payload.get("user");
String userid = user.get("userid").getAsString();
for (MessageListener listener : listeners) {
listener.handle(new UserLeft(meetingId, userid));
}
} else if (MessagingConstants.USER_JOINED_VOICE_EVENT.equalsIgnoreCase(messageName)) {
String meetingId = payload.get("meeting_id").getAsString();
JsonObject user = (JsonObject) payload.get("user");
String userid = user.get("userid").getAsString();
for (MessageListener listener : listeners) {
listener.handle(new UserJoinedVoice(meetingId, userid));
}
} else if (MessagingConstants.USER_LEFT_VOICE_EVENT.equalsIgnoreCase(messageName)) {
String meetingId = payload.get("meeting_id").getAsString();
JsonObject user = (JsonObject) payload.get("user");
String userid = user.get("userid").getAsString();
for (MessageListener listener : listeners) {
listener.handle(new UserLeftVoice(meetingId, userid));
}
} else if (MessagingConstants.USER_LISTEN_ONLY_EVENT.equalsIgnoreCase(messageName)) {
String meetingId = payload.get("meeting_id").getAsString();
String userid = payload.get("userid").getAsString();
Boolean listenOnly = payload.get("listen_only").getAsBoolean();
for (MessageListener listener : listeners) {
listener.handle(new UserListeningOnly(meetingId, userid, listenOnly));
}
} else if (MessagingConstants.USER_SHARE_WEBCAM_EVENT.equalsIgnoreCase(messageName)) {
String meetingId = payload.get("meeting_id").getAsString();
String userid = payload.get("userid").getAsString();
String stream = payload.get("stream").getAsString();
for (MessageListener listener : listeners) {
listener.handle(new UserSharedWebcam(meetingId, userid, stream));
}
} else if (MessagingConstants.USER_UNSHARE_WEBCAM_EVENT.equalsIgnoreCase(messageName)) {
String meetingId = payload.get("meeting_id").getAsString();
String userid = payload.get("userid").getAsString();
String stream = payload.get("stream").getAsString();
for (MessageListener listener : listeners) {
listener.handle(new UserUnsharedWebcam(meetingId, userid, stream));
}
} else if (MessagingConstants.USER_ROLE_CHANGE_EVENT.equalsIgnoreCase(messageName)) {
String meetingId = payload.get("meeting_id").getAsString();
String userid = payload.get("userid").getAsString();
String role = payload.get("role").getAsString();
for (MessageListener listener : listeners) {
listener.handle(new UserRoleChanged(meetingId, userid, role));
}
} else if (SendStunTurnInfoRequestMessage.SEND_STUN_TURN_INFO_REQUEST_MESSAGE.equalsIgnoreCase(messageName)) {
String meetingId = payload.get(Constants.MEETING_ID).getAsString();
String requesterId = payload.get(Constants.REQUESTER_ID).getAsString();
for (MessageListener listener : listeners) {
listener.handle(new StunTurnInfoRequested(meetingId, requesterId));
}
}
}
}
}
*/
}
}

View File

@ -1,12 +1,14 @@
package org.bigbluebutton.api.messaging;
import org.bigbluebutton.api.messaging.messages.IMessage;
import java.util.Set;
public class MessageDistributor {
private ReceivedMessageHandler handler;
private Set<MessageHandler> listeners;
private Set<MessageListener> listeners;
public void setMessageListeners(Set<MessageHandler> listeners) {
public void setMessageListeners(Set<MessageListener> listeners) {
this.listeners = listeners;
}
@ -17,9 +19,9 @@ public class MessageDistributor {
}
}
public void notifyListeners(String pattern, String channel, String message) {
for (MessageHandler listener : listeners) {
listener.handleMessage(pattern, channel, message);
public void notifyListeners(IMessage message) {
for (MessageListener listener : listeners) {
listener.handle(message);
}
}
}

View File

@ -1,23 +1,24 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* 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
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
*/
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
* <p>
* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below).
* <p>
* 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
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
* <p>
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* <p>
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*/
package org.bigbluebutton.api.messaging;
import org.bigbluebutton.api.messaging.messages.IMessage;
public interface MessageHandler {
void handleMessage(String pattern, String channel, String message);
void handleMessage(IMessage message);
}

View File

@ -1,21 +1,20 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* 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
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
*/
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
* <p>
* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below).
* <p>
* 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
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
* <p>
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* <p>
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*/
package org.bigbluebutton.api.messaging;

View File

@ -1,115 +0,0 @@
package org.bigbluebutton.api.messaging;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPubSub;
import redis.clients.jedis.exceptions.JedisConnectionException;
public class MessageReceiver {
private static Logger log = LoggerFactory.getLogger(MessageReceiver.class);
private ReceivedMessageHandler handler;
private Jedis jedis;
private volatile boolean receiveMessage = false;
private final Executor msgReceiverExec = Executors.newSingleThreadExecutor();
private final Executor runExec = Executors.newSingleThreadExecutor();
private String host;
private int port;
public void stop() {
receiveMessage = false;
}
public void start() {
log.info("Ready to receive messages from Redis pubsub.");
try {
receiveMessage = true;
jedis = new Jedis(host, port);
// Set the name of this client to be able to distinguish when doing
// CLIENT LIST on redis-cli
jedis.clientSetname("BbbWebSub");
Runnable messageReceiver = new Runnable() {
public void run() {
if (receiveMessage) {
try {
jedis.psubscribe(new PubSubListener(), MessagingConstants.FROM_BBB_APPS_PATTERN);
} catch(JedisConnectionException ex) {
log.warn("Exception on Jedis connection. Resubscribing to pubsub.");
start();
} catch (Exception e) {
log.error("Error resubscribing to channels: " + e.getMessage());
}
}
}
};
msgReceiverExec.execute(messageReceiver);
} catch (Exception e) {
log.error("Error subscribing to channels: " + e.getMessage());
}
}
public void setHost(String host){
this.host = host;
}
public void setPort(int port) {
this.port = port;
}
public void setMessageHandler(ReceivedMessageHandler handler) {
this.handler = handler;
}
private class PubSubListener extends JedisPubSub {
public PubSubListener() {
super();
}
@Override
public void onMessage(String channel, String message) {
// Not used.
}
@Override
public void onPMessage(final String pattern, final String channel, final String message) {
Runnable task = new Runnable() {
public void run() {
handler.handleMessage(pattern, channel, message);
}
};
runExec.execute(task);
}
@Override
public void onPSubscribe(String pattern, int subscribedChannels) {
log.debug("Subscribed to the pattern: " + pattern);
}
@Override
public void onPUnsubscribe(String pattern, int subscribedChannels) {
// Not used.
}
@Override
public void onSubscribe(String channel, int subscribedChannels) {
// Not used.
}
@Override
public void onUnsubscribe(String channel, int subscribedChannels) {
// Not used.
}
}
}

View File

@ -1,25 +1,25 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* 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
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
*/
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
* <p>
* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below).
* <p>
* 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
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
* <p>
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* <p>
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*/
package org.bigbluebutton.api.messaging;
import org.bigbluebutton.presentation.messages.IDocConversionMsg;
import org.bigbluebutton.web.services.turn.StunServer;
import org.bigbluebutton.web.services.turn.TurnEntry;
@ -28,11 +28,17 @@ import java.util.Set;
public interface MessagingService {
void recordMeetingInfo(String meetingId, Map<String, String> info);
void recordBreakoutInfo(String meetingId, Map<String, String> breakoutInfo);
void addBreakoutRoom(String parentId, String breakoutId);
/*
void send(String channel, String message);
void publishRecording(String recordId, String meetingId, String externalMeetingId, String format, boolean publish);
void deleteRecording(String recordId, String meetingId, String externalMeetingId, String format);
void createMeeting(String meetingID, String externalMeetingID,
String parentMeetingID, String meetingName, Boolean recorded,
String voiceBridge, Integer duration, Boolean autoStartRecording,
@ -40,10 +46,18 @@ public interface MessagingService {
String moderatorPass, String viewerPass, Long createTime,
String createDate, Boolean isBreakout, Integer sequence,
Map<String, String> metadata, String guestPolicy);
void registerUser(String meetingID, String internalUserId, String fullname, String role,
String externUserID, String authToken, String avatarURL, Boolean guest, Boolean authed);
void destroyMeeting(String meetingID);
void endMeeting(String meetingId);
void sendKeepAlive(String system, Long timestamp);
void sendStunTurnInfo(String meetingId, String internalUserId, Set<StunServer> stuns, Set<TurnEntry> turns);
void sendDocConversionMsg(IDocConversionMsg msg);
*/
}

View File

@ -1,25 +1,16 @@
package org.bigbluebutton.api.messaging;
public class ReceivedMessage {
private final String pattern;
private final String channel;
private final String message;
import org.bigbluebutton.api.messaging.messages.IMessage;
public class ReceivedMessage {
private final IMessage message;
public ReceivedMessage(IMessage message) {
public ReceivedMessage(String pattern, String channel, String message) {
this.pattern = pattern;
this.channel = channel;
this.message = message;
}
public String getPattern() {
return pattern;
}
public String getChannel() {
return channel;
}
public String getMessage() {
public IMessage getMessage() {
return message;
}
}

View File

@ -1,11 +1,13 @@
package org.bigbluebutton.api.messaging;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import org.bigbluebutton.api.IReceivedOldMessageHandler;
import org.bigbluebutton.api.messaging.messages.IMessage;
import org.bigbluebutton.api2.bus.OldMessageReceivedGW;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -19,7 +21,7 @@ public class ReceivedMessageHandler implements IReceivedOldMessageHandler {
private final Executor msgProcessorExec = Executors.newSingleThreadExecutor();
private final Executor runExec = Executors.newSingleThreadExecutor();
private MessageDistributor handler;
private MessageDistributor outGW;
public void stop() {
processMessage = false;
@ -49,28 +51,26 @@ public class ReceivedMessageHandler implements IReceivedOldMessageHandler {
}
}
private void notifyListeners(IMessage message) {
outGW.notifyListeners(message);
}
private void processMessage(final ReceivedMessage msg) {
Runnable task = new Runnable() {
public void run() {
if (handler != null) {
// log.debug("Let's process this message: " + msg.getMessage());
handler.notifyListeners(msg.getPattern(), msg.getChannel(), msg.getMessage());
} else {
log.warn("No listeners interested in messages from Redis!");
}
notifyListeners(msg.getMessage());
}
};
runExec.execute(task);
}
public void handleMessage(String pattern, String channel, String message) {
ReceivedMessage rm = new ReceivedMessage(pattern, channel, message);
public void handleMessage(IMessage message) {
ReceivedMessage rm = new ReceivedMessage(message);
receivedMessages.add(rm);
}
public void setMessageDistributor(MessageDistributor h) {
this.handler = h;
public void setMessageDistributor(MessageDistributor outGW) {
this.outGW = outGW;
}
}

View File

@ -1,21 +1,20 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* 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
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
*/
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
* <p>
* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below).
* <p>
* 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
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
* <p>
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* <p>
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*/
package org.bigbluebutton.api.messaging;
@ -31,6 +30,7 @@ import org.bigbluebutton.api.messaging.converters.messages.DestroyMeetingMessage
import org.bigbluebutton.api.messaging.converters.messages.EndMeetingMessage;
import org.bigbluebutton.api.messaging.converters.messages.PublishRecordingMessage;
import org.bigbluebutton.api.messaging.converters.messages.UnpublishRecordingMessage;
import org.bigbluebutton.api2.IBbbWebApiGWApp;
import org.bigbluebutton.common.converters.ToJsonEncoder;
import org.bigbluebutton.common.messages.Constants;
import org.bigbluebutton.common.messages.MessagingConstants;
@ -39,6 +39,7 @@ import org.bigbluebutton.messages.CreateMeetingRequest;
import org.bigbluebutton.messages.CreateMeetingRequestPayload;
import org.bigbluebutton.messages.RegisterUserMessage;
import org.bigbluebutton.messages.RegisterUserMessagePayload;
import org.bigbluebutton.presentation.messages.IDocConversionMsg;
import org.bigbluebutton.web.services.turn.StunServer;
import org.bigbluebutton.web.services.turn.TurnEntry;
import org.slf4j.Logger;
@ -46,30 +47,13 @@ import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
public class RedisMessagingService implements MessagingService {
public class RedisMessagingService {
private static Logger log = LoggerFactory.getLogger(RedisMessagingService.class);
private RedisStorageService storeService;
private MessageSender sender;
private ToJsonEncoder encoder = new ToJsonEncoder();
public void recordMeetingInfo(String meetingId, Map<String, String> info) {
storeService.recordMeetingInfo(meetingId, info);
}
public void recordBreakoutInfo(String meetingId, Map<String, String> breakoutInfo) {
storeService.recordBreakoutInfo(meetingId, breakoutInfo);
}
public void addBreakoutRoom(String parentId, String breakoutId) {
storeService.addBreakoutRoom(parentId, breakoutId);
}
public void destroyMeeting(String meetingID) {
DestroyMeetingMessage msg = new DestroyMeetingMessage(meetingID);
String json = MessageToJson.destroyMeetingMessageToJson(msg);
log.info("Sending destroy meeting message to bbb-apps:[{}]", json);
sender.send(MessagingConstants.TO_MEETING_CHANNEL, json);
}
public void registerUser(String meetingID, String internalUserId, String fullname, String role,
@ -81,7 +65,7 @@ public class RedisMessagingService implements MessagingService {
Gson gson = new Gson();
String json = gson.toJson(msg);
log.info("*****Sending register user message to bbb-apps:[{}]", json);
sender.send(MessagingConstants.TO_MEETING_CHANNEL, json);
}
public void createMeeting(String meetingID, String externalMeetingID,
@ -102,26 +86,25 @@ public class RedisMessagingService implements MessagingService {
Gson gson = new Gson();
String json = gson.toJson(msg);
log.info("Sending create meeting message to bbb-apps:[{}]", json);
sender.send(MessagingConstants.TO_MEETING_CHANNEL, json);
}
public void endMeeting(String meetingId) {
EndMeetingMessage msg = new EndMeetingMessage(meetingId);
String json = MessageToJson.endMeetingMessageToJson(msg);
log.info("Sending end meeting message to bbb-apps:[{}]", json);
sender.send(MessagingConstants.TO_MEETING_CHANNEL, json);
}
public void sendKeepAlive(String system, Long timestamp) {
String json = encoder.encodePubSubPingMessage("BbbWeb", System.currentTimeMillis());
sender.send(MessagingConstants.TO_SYSTEM_CHANNEL, json);
}
public void send(String channel, String message) {
sender.send(channel, message);
}
public void sendPolls(String meetingId, String title, String question, String questionType, List<String> answers){
public void sendPolls(String meetingId, String title, String question, String questionType, List<String> answers) {
Gson gson = new Gson();
HashMap<String, Object> map = new HashMap<String, Object>();
@ -132,76 +115,45 @@ public class RedisMessagingService implements MessagingService {
map.put("questionType", questionType);
map.put("answers", answers);
sender.send(MessagingConstants.TO_POLLING_CHANNEL, gson.toJson(map));
}
public void setMessageSender(MessageSender sender) {
this.sender = sender;
}
public void setRedisStorageService(RedisStorageService storeService) {
this.storeService = storeService;
}
public void publishRecording(PublishRecordingMessage msg) {
public void removeMeeting(String meetingId){
storeService.removeMeeting(meetingId);
}
private void publishRecording(String recordId, String meetingId, String externalMeetingId, String format) {
PublishRecordingMessage msg = new PublishRecordingMessage(recordId, meetingId, externalMeetingId, format);
String json = MessageToJson.publishRecordingMessageToJson(msg);
sender.send(MessagingConstants.FROM_BBB_RECORDING_CHANNEL, json);
}
private void unpublishRecording(String recordId, String meetingId, String externalMeetingId, String format) {
UnpublishRecordingMessage msg = new UnpublishRecordingMessage(recordId, meetingId, externalMeetingId, format);
public void unpublishRecording(UnpublishRecordingMessage msg) {
String json = MessageToJson.unpublishRecordingMessageToJson(msg);
sender.send(MessagingConstants.FROM_BBB_RECORDING_CHANNEL, json);
}
public void publishRecording(String recordId, String meetingId, String externalMeetingId, String format, boolean publish) {
if (publish) {
publishRecording(recordId, meetingId, externalMeetingId, format);
PublishRecordingMessage msg = new PublishRecordingMessage(recordId, meetingId, externalMeetingId, format);
publishRecording(msg);
} else {
unpublishRecording(recordId, meetingId, externalMeetingId, format);
UnpublishRecordingMessage msg = new UnpublishRecordingMessage(recordId, meetingId, externalMeetingId, format);
unpublishRecording(msg);
}
}
public void deleteRecording(String recordId, String meetingId, String externalMeetingId, String format) {
DeleteRecordingMessage msg = new DeleteRecordingMessage(recordId, meetingId, externalMeetingId, format);
String json = MessageToJson.deleteRecordingMessageToJson(msg);
sender.send(MessagingConstants.FROM_BBB_RECORDING_CHANNEL, json);
}
public void sendStunTurnInfo(String meetingId, String internalUserId, Set<StunServer> stuns, Set<TurnEntry> turns) {
ArrayList<String> stunsArrayList = new ArrayList<String>();
Iterator<StunServer> stunsIter = stuns.iterator();
while (stunsIter.hasNext()) {
StunServer aStun = (StunServer) stunsIter.next();
if (aStun != null) {
stunsArrayList.add(aStun.url);
}
}
ArrayList<Map<String, Object>> turnsArrayList = new ArrayList<Map<String, Object>>();
Iterator<TurnEntry> turnsIter = turns.iterator();
while (turnsIter.hasNext()) {
TurnEntry te = (TurnEntry) turnsIter.next();
if (null != te) {
Map<String, Object> map = new HashMap<String, Object>();
map.put(Constants.USERNAME, te.username);
map.put(Constants.URL, te.url);
map.put(Constants.TTL, te.ttl);
map.put(Constants.PASSWORD, te.password);
public void sendDocConversionMsg(IDocConversionMsg msg) {
turnsArrayList.add(map);
}
}
SendStunTurnInfoReplyMessage msg = new SendStunTurnInfoReplyMessage(meetingId, internalUserId,
stunsArrayList, turnsArrayList);
sender.send(MessagingConstants.TO_BBB_HTML5_CHANNEL, msg.toJson());
}
}

View File

@ -69,7 +69,7 @@ public class RedisStorageService {
}
}
public void removeMeeting(String meetingId){
public void removeMeeting(String meetingId) {
Jedis jedis = redisPool.getResource();
try {
jedis.del("meeting-" + meetingId);
@ -79,7 +79,7 @@ public class RedisStorageService {
}
}
public void setHost(String host){
public void setHost(String host) {
this.host = host;
}

View File

@ -1,6 +1,10 @@
package org.bigbluebutton.api2;
import org.bigbluebutton.api.messaging.converters.messages.*;
import org.bigbluebutton.common.messages.SendStunTurnInfoReplyMessage;
import org.bigbluebutton.presentation.messages.IDocConversionMsg;
import java.util.Map;
public interface IBbbWebApiGWApp {
@ -15,4 +19,13 @@ public interface IBbbWebApiGWApp {
String dialNumber, Integer maxUsers);
void registerUser(String meetingID, String internalUserId, String fullname, String role,
String externUserID, String authToken, String avatarURL, Boolean guest, Boolean authed);
void destroyMeeting(DestroyMeetingMessage msg);
void endMeeting(EndMeetingMessage msg);
void sendKeepAlive(String system, Long timestamp);
void publishRecording(PublishRecordingMessage msg);
void unpublishRecording(UnpublishRecordingMessage msg);
void deleteRecording(DeleteRecordingMessage msg);
void sendStunTurnInfoReply(SendStunTurnInfoReplyMessage msg);
void sendDocConversionMsg(IDocConversionMsg msg);
}

View File

@ -20,6 +20,7 @@
package org.bigbluebutton.presentation;
import org.bigbluebutton.api.messaging.MessagingService;
import org.bigbluebutton.api2.IBbbWebApiGWApp;
import org.bigbluebutton.presentation.imp.ImageToSwfSlidesGenerationService;
import org.bigbluebutton.presentation.imp.OfficeToPdfConversionService;
import org.bigbluebutton.presentation.imp.PdfToSwfSlidesGenerationService;
@ -30,13 +31,13 @@ public class DocumentConversionServiceImp implements DocumentConversionService {
private static Logger log = LoggerFactory
.getLogger(DocumentConversionServiceImp.class);
private MessagingService messagingService;
private IBbbWebApiGWApp gw;
private OfficeToPdfConversionService officeToPdfConversionService;
private PdfToSwfSlidesGenerationService pdfToSwfSlidesGenerationService;
private ImageToSwfSlidesGenerationService imageToSwfSlidesGenerationService;
public void processDocument(UploadedPresentation pres) {
SupportedDocumentFilter sdf = new SupportedDocumentFilter(messagingService);
SupportedDocumentFilter sdf = new SupportedDocumentFilter(gw);
log.info("Start presentation conversion. meetingId=" + pres.getMeetingId()
+ " presId=" + pres.getId() + " name=" + pres.getName());
@ -45,8 +46,7 @@ public class DocumentConversionServiceImp implements DocumentConversionService {
if (SupportedFileTypes.isOfficeFile(fileType)) {
pres = officeToPdfConversionService.convertOfficeToPdf(pres);
OfficeToPdfConversionSuccessFilter ocsf = new OfficeToPdfConversionSuccessFilter(
messagingService);
OfficeToPdfConversionSuccessFilter ocsf = new OfficeToPdfConversionSuccessFilter(gw);
if (ocsf.didConversionSucceed(pres)) {
// Successfully converted to pdf. Call the process again, this time it
// should be handled by
@ -70,8 +70,8 @@ public class DocumentConversionServiceImp implements DocumentConversionService {
}
public void setMessagingService(MessagingService m) {
messagingService = m;
public void setBbbWebApiGWApp(IBbbWebApiGWApp m) {
gw = m;
}
public void setOfficeToPdfConversionService(OfficeToPdfConversionService s) {

View File

@ -24,21 +24,22 @@ import java.util.Map;
import org.bigbluebutton.api.messaging.MessagingConstants;
import org.bigbluebutton.api.messaging.MessagingService;
import org.bigbluebutton.api2.IBbbWebApiGWApp;
import org.bigbluebutton.presentation.messages.OfficeDocConversionProgress;
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 static Logger log = LoggerFactory.getLogger(OfficeToPdfConversionSuccessFilter.class);
private final MessagingService messagingService;
private final IBbbWebApiGWApp gw;
private static Map<String, String> conversionMessagesMap;
public OfficeToPdfConversionSuccessFilter(MessagingService m) {
messagingService = m;
public OfficeToPdfConversionSuccessFilter(IBbbWebApiGWApp m) {
gw = m;
conversionMessagesMap = new HashMap<String, String>();
conversionMessagesMap.put(
ConversionMessageConstants.OFFICE_DOC_CONVERSION_SUCCESS_KEY,
@ -70,18 +71,16 @@ public class OfficeToPdfConversionSuccessFilter {
log.info("Notifying of " + pres.getConversionStatus() + " for "
+ pres.getUploadedFile().getAbsolutePath());
sendNotification(msg);
sendProgress(pres);
}
private void sendNotification(Map<String, Object> msg) {
if (messagingService != null) {
Gson gson = new Gson();
String updateMsg = gson.toJson(msg);
log.debug("sending: " + updateMsg);
messagingService.send(MessagingConstants.TO_PRESENTATION_CHANNEL,
updateMsg);
} else {
log.warn("MessagingService has not been set!.");
}
public void sendProgress(UploadedPresentation pres) {
OfficeDocConversionProgress progress = new OfficeDocConversionProgress(pres.getMeetingId(),
pres.getId(), pres.getId(),
pres.getName(), "notUsedYet", "notUsedYet",
pres.isDownloadable(), pres.getConversionStatus());
gw.sendDocConversionMsg(progress);
}
}

View File

@ -1,21 +1,20 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* 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
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
*/
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
* <p>
* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below).
* <p>
* 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
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
* <p>
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* <p>
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*/
package org.bigbluebutton.presentation;
@ -24,7 +23,9 @@ import java.io.File;
import org.apache.commons.io.FilenameUtils;
import org.bigbluebutton.api.messaging.MessagingConstants;
import org.bigbluebutton.api.messaging.MessagingService;
import org.bigbluebutton.api2.IBbbWebApiGWApp;
import org.bigbluebutton.presentation.ConversionUpdateMessage.MessageBuilder;
import org.bigbluebutton.presentation.messages.OfficeDocConversionProgress;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -33,10 +34,10 @@ import com.google.gson.Gson;
public class SupportedDocumentFilter {
private static Logger log = LoggerFactory.getLogger(SupportedDocumentFilter.class);
private final MessagingService messagingService;
private final IBbbWebApiGWApp gw;
public SupportedDocumentFilter(MessagingService m) {
messagingService = m;
public SupportedDocumentFilter(IBbbWebApiGWApp m) {
gw = m;
}
public boolean isSupported(UploadedPresentation pres) {
@ -49,8 +50,7 @@ public class SupportedDocumentFilter {
if (supported) {
log.info("Received supported file {}", pres.getUploadedFile().getAbsolutePath());
pres.setFileType(extension);
}
else {
} else {
log.warn("Received not supported file {}", pres.getUploadedFile().getAbsolutePath());
}
return supported;
@ -59,17 +59,22 @@ public class SupportedDocumentFilter {
private void notifyProgressListener(boolean supported, UploadedPresentation pres) {
MessageBuilder builder = new ConversionUpdateMessage.MessageBuilder(pres);
String msgKey = ConversionMessageConstants.SUPPORTED_DOCUMENT_KEY;
if (supported) {
builder.messageKey(ConversionMessageConstants.SUPPORTED_DOCUMENT_KEY);
msgKey = ConversionMessageConstants.SUPPORTED_DOCUMENT_KEY;
} else {
builder.messageKey(ConversionMessageConstants.UNSUPPORTED_DOCUMENT_KEY);
msgKey = ConversionMessageConstants.UNSUPPORTED_DOCUMENT_KEY;
}
if(messagingService !=null){
Gson gson= new Gson();
String updateMsg=gson.toJson(builder.build().getMessage());
log.debug("sending: "+updateMsg);
messagingService.send(MessagingConstants.TO_PRESENTATION_CHANNEL, updateMsg);
if (gw != null) {
OfficeDocConversionProgress progress = new OfficeDocConversionProgress(pres.getMeetingId(),
pres.getId(), pres.getId(),
pres.getName(), "notUsedYet", "notUsedYet",
pres.isDownloadable(), msgKey);
gw.sendDocConversionMsg(progress);
} else {
log.warn("MessagingService has not been set!");
}

View File

@ -29,8 +29,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class OfficeToPdfConversionService {
private static Logger log = LoggerFactory
.getLogger(OfficeToPdfConversionService.class);
private static Logger log = LoggerFactory.getLogger(OfficeToPdfConversionService.class);
private OfficeDocumentValidator officeDocumentValidator;

View File

@ -42,14 +42,15 @@ import org.bigbluebutton.presentation.SvgImageCreator;
import org.bigbluebutton.presentation.TextFileCreator;
import org.bigbluebutton.presentation.ThumbnailCreator;
import org.bigbluebutton.presentation.UploadedPresentation;
import org.bigbluebutton.presentation.messages.DocPageCountExceeded;
import org.bigbluebutton.presentation.messages.DocPageCountFailed;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
public class PdfToSwfSlidesGenerationService {
private static Logger log = LoggerFactory
.getLogger(PdfToSwfSlidesGenerationService.class);
private static Logger log = LoggerFactory.getLogger(PdfToSwfSlidesGenerationService.class);
private SwfSlidesGenerationProgressNotifier notifier;
private PageCounterService counterService;
@ -94,20 +95,33 @@ public class PdfToSwfSlidesGenerationService {
return false;
}
private void sendFailedToCountPageMessage(CountingPageException e,
UploadedPresentation pres) {
private void sendFailedToCountPageMessage(CountingPageException e, UploadedPresentation pres) {
MessageBuilder builder = new ConversionUpdateMessage.MessageBuilder(pres);
if (e
.getExceptionType() == CountingPageException.ExceptionType.PAGE_COUNT_EXCEPTION) {
if (e.getExceptionType() == CountingPageException.ExceptionType.PAGE_COUNT_EXCEPTION) {
builder.messageKey(ConversionMessageConstants.PAGE_COUNT_FAILED_KEY);
} else if (e
.getExceptionType() == CountingPageException.ExceptionType.PAGE_EXCEEDED_EXCEPTION) {
DocPageCountFailed progress = new DocPageCountFailed(pres.getMeetingId(),
pres.getId(), pres.getId(),
pres.getName(), "notUsedYet", "notUsedYet",
pres.isDownloadable(), ConversionMessageConstants.PAGE_COUNT_FAILED_KEY);
notifier.sendDocConversionProgress(progress);
} else if (e.getExceptionType() == CountingPageException.ExceptionType.PAGE_EXCEEDED_EXCEPTION) {
builder.numberOfPages(e.getPageCount());
builder.maxNumberPages(e.getMaxNumberOfPages());
builder.messageKey(ConversionMessageConstants.PAGE_COUNT_EXCEEDED_KEY);
DocPageCountExceeded progress = new DocPageCountExceeded(pres.getMeetingId(),
pres.getId(), pres.getId(),
pres.getName(), "notUsedYet", "notUsedYet",
pres.isDownloadable(), ConversionMessageConstants.PAGE_COUNT_EXCEEDED_KEY,
e.getPageCount(), e.getMaxNumberOfPages());
notifier.sendDocConversionProgress(progress);
}
notifier.sendConversionUpdateMessage(builder.build().getMessage());
}
private void createThumbnails(UploadedPresentation pres) {

View File

@ -1,71 +1,62 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* 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
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
*/
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
* <p>
* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below).
* <p>
* 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
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
* <p>
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* <p>
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*/
package org.bigbluebutton.presentation.imp;
import java.util.Map;
import org.bigbluebutton.api.messaging.MessagingConstants;
import org.bigbluebutton.api.messaging.MessagingService;
import org.bigbluebutton.api2.IBbbWebApiGWApp;
import org.bigbluebutton.presentation.ConversionMessageConstants;
import org.bigbluebutton.presentation.ConversionUpdateMessage;
import org.bigbluebutton.presentation.ConversionUpdateMessage.MessageBuilder;
import org.bigbluebutton.presentation.GeneratedSlidesInfoHelper;
import org.bigbluebutton.presentation.UploadedPresentation;
import org.bigbluebutton.presentation.messages.DocPageCompletedProgress;
import org.bigbluebutton.presentation.messages.DocPageGeneratedProgress;
import org.bigbluebutton.presentation.messages.IDocConversionMsg;
import org.bigbluebutton.presentation.messages.OfficeDocConversionProgress;
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 MessagingService messagingService;
private IBbbWebApiGWApp messagingService;
private GeneratedSlidesInfoHelper generatedSlidesInfoHelper;
private void notifyProgressListener(Map<String, Object> msg) {
if(messagingService != null){
Gson gson= new Gson();
String updateMsg = gson.toJson(msg);
messagingService.send(MessagingConstants.TO_PRESENTATION_CHANNEL, updateMsg);
} else {
log.warn("MessagingService has not been set");
}
public void sendDocConversionProgress(IDocConversionMsg msg) {
messagingService.sendDocConversionMsg(msg);
}
public void sendConversionUpdateMessage(Map<String, Object> message) {
notifyProgressListener(message);
}
public void sendConversionUpdateMessage(int slidesCompleted, UploadedPresentation pres) {
MessageBuilder builder = new ConversionUpdateMessage.MessageBuilder(pres);
builder.messageKey(ConversionMessageConstants.GENERATED_SLIDE_KEY);
builder.numberOfPages(pres.getNumberOfPages());
builder.pagesCompleted(slidesCompleted);
notifyProgressListener(builder.build().getMessage());
DocPageGeneratedProgress progress = new DocPageGeneratedProgress(pres.getMeetingId(),
pres.getId(), pres.getId(),
pres.getName(), "notUsedYet", "notUsedYet",
pres.isDownloadable(), ConversionMessageConstants.GENERATED_SLIDE_KEY,
pres.getNumberOfPages(), slidesCompleted);
messagingService.sendDocConversionMsg(progress);
}
public void sendCreatingThumbnailsUpdateMessage(UploadedPresentation pres) {
MessageBuilder builder = new ConversionUpdateMessage.MessageBuilder(pres);
builder.messageKey(ConversionMessageConstants.GENERATING_THUMBNAIL_KEY);
notifyProgressListener(builder.build().getMessage());
OfficeDocConversionProgress progress = new OfficeDocConversionProgress(pres.getMeetingId(),
pres.getId(), pres.getId(),
pres.getName(), "notUsedYet", "notUsedYet",
pres.isDownloadable(), ConversionMessageConstants.GENERATING_THUMBNAIL_KEY);
messagingService.sendDocConversionMsg(progress);
}
public void sendConversionCompletedMessage(UploadedPresentation pres) {
@ -74,14 +65,19 @@ public class SwfSlidesGenerationProgressNotifier {
return;
}
MessageBuilder builder = new ConversionUpdateMessage.MessageBuilder(pres);
builder.messageKey(ConversionMessageConstants.CONVERSION_COMPLETED_KEY);
builder.numberOfPages(pres.getNumberOfPages());
builder.presBaseUrl(pres);
notifyProgressListener(builder.build().getMessage());
DocPageCompletedProgress progress = new DocPageCompletedProgress(pres.getMeetingId(),
pres.getId(), pres.getId(),
pres.getName(), "notUsedYet", "notUsedYet",
pres.isDownloadable(), ConversionMessageConstants.CONVERSION_COMPLETED_KEY,
pres.getNumberOfPages(), generateBasePresUrl(pres));
messagingService.sendDocConversionMsg(progress);
}
public void setMessagingService(MessagingService m) {
private String generateBasePresUrl(UploadedPresentation pres) {
return pres.getBaseUrl() + "/" + pres.getMeetingId() + "/" + pres.getMeetingId() + "/" + pres.getId();
}
public void setMessagingService(IBbbWebApiGWApp m) {
messagingService = m;
}
@ -90,14 +86,18 @@ public class SwfSlidesGenerationProgressNotifier {
}
public void sendCreatingTextFilesUpdateMessage(UploadedPresentation pres) {
MessageBuilder builder = new ConversionUpdateMessage.MessageBuilder(pres);
builder.messageKey(ConversionMessageConstants.GENERATING_TEXTFILES_KEY);
notifyProgressListener(builder.build().getMessage());
OfficeDocConversionProgress progress = new OfficeDocConversionProgress(pres.getMeetingId(),
pres.getId(), pres.getId(),
pres.getName(), "notUsedYet", "notUsedYet",
pres.isDownloadable(), ConversionMessageConstants.GENERATING_TEXTFILES_KEY);
messagingService.sendDocConversionMsg(progress);
}
public void sendCreatingSvgImagesUpdateMessage(UploadedPresentation pres) {
MessageBuilder builder = new ConversionUpdateMessage.MessageBuilder(pres);
builder.messageKey(ConversionMessageConstants.GENERATING_SVGIMAGES_KEY);
notifyProgressListener(builder.build().getMessage());
OfficeDocConversionProgress progress = new OfficeDocConversionProgress(pres.getMeetingId(),
pres.getId(), pres.getId(),
pres.getName(), "notUsedYet", "notUsedYet",
pres.isDownloadable(), ConversionMessageConstants.GENERATING_SVGIMAGES_KEY);
messagingService.sendDocConversionMsg(progress);
}
}

View File

@ -0,0 +1,30 @@
package org.bigbluebutton.presentation.messages;
public class DocPageCompletedProgress implements IDocConversionMsg {
public final String meetingId;
public final String presId;
public final String presInstance;
public final String filename;
public final String uploaderId;
public final String authzToken;
public final Boolean downloadable;
public final String key;
public final Integer numPages;
public final String presBaseUrl;
public DocPageCompletedProgress(String meetingId, String presId, String presInstance,
String filename, String uploaderId, String authzToken,
Boolean downloadable, String key,
Integer numPages, String presBaseUrl) {
this.meetingId = meetingId;
this.presId = presId;
this.presInstance = presInstance;
this.filename = filename;
this.uploaderId = uploaderId;
this.authzToken = authzToken;
this.downloadable = downloadable;
this.key = key;
this.numPages = numPages;
this.presBaseUrl = presBaseUrl;
}
}

View File

@ -0,0 +1,30 @@
package org.bigbluebutton.presentation.messages;
public class DocPageCountExceeded implements IDocConversionMsg {
public final String meetingId;
public final String presId;
public final String presInstance;
public final String filename;
public final String uploaderId;
public final String authzToken;
public final Boolean downloadable;
public final String key;
public final Integer numPages;
public final Integer maxNumPages;
public DocPageCountExceeded(String meetingId, String presId, String presInstance,
String filename, String uploaderId, String authzToken,
Boolean downloadable, String key,
Integer numPages, Integer maxNumPages) {
this.meetingId = meetingId;
this.presId = presId;
this.presInstance = presInstance;
this.filename = filename;
this.uploaderId = uploaderId;
this.authzToken = authzToken;
this.downloadable = downloadable;
this.key = key;
this.numPages = numPages;
this.maxNumPages = maxNumPages;
}
}

View File

@ -0,0 +1,25 @@
package org.bigbluebutton.presentation.messages;
public class DocPageCountFailed implements IDocConversionMsg {
public final String meetingId;
public final String presId;
public final String presInstance;
public final String filename;
public final String uploaderId;
public final String authzToken;
public final Boolean downloadable;
public final String key;
public DocPageCountFailed(String meetingId, String presId, String presInstance,
String filename, String uploaderId, String authzToken,
Boolean downloadable, String key) {
this.meetingId = meetingId;
this.presId = presId;
this.presInstance = presInstance;
this.filename = filename;
this.uploaderId = uploaderId;
this.authzToken = authzToken;
this.downloadable = downloadable;
this.key = key;
}
}

View File

@ -0,0 +1,30 @@
package org.bigbluebutton.presentation.messages;
public class DocPageGeneratedProgress implements IDocConversionMsg {
public final String meetingId;
public final String presId;
public final String presInstance;
public final String filename;
public final String uploaderId;
public final String authzToken;
public final Boolean downloadable;
public final String key;
public final Integer numPages;
public final Integer pagesCompleted;
public DocPageGeneratedProgress(String meetingId, String presId, String presInstance,
String filename, String uploaderId, String authzToken,
Boolean downloadable, String key,
Integer numPages, Integer pagesCompleted) {
this.meetingId = meetingId;
this.presId = presId;
this.presInstance = presInstance;
this.filename = filename;
this.uploaderId = uploaderId;
this.authzToken = authzToken;
this.downloadable = downloadable;
this.key = key;
this.numPages = numPages;
this.pagesCompleted = pagesCompleted;
}
}

View File

@ -0,0 +1,5 @@
package org.bigbluebutton.presentation.messages;
public interface IDocConversionMsg {
}

View File

@ -0,0 +1,26 @@
package org.bigbluebutton.presentation.messages;
import org.bigbluebutton.api.messaging.messages.IMessage;
public class OfficeDocConversionInvalid implements IMessage{
public final String meetingId;
public final String presId;
public final String presInstance;
public final String filename;
public final String uploaderId;
public final String authzToken;
public final Boolean downloadable;
public OfficeDocConversionInvalid(String meetingId, String presId, String presInstance,
String filename, String uploaderId, String authzToken,
Boolean downloadable) {
this.meetingId = meetingId;
this.presId = presId;
this.presInstance = presInstance;
this.filename = filename;
this.uploaderId = uploaderId;
this.authzToken = authzToken;
this.downloadable = downloadable;
}
}

View File

@ -0,0 +1,28 @@
package org.bigbluebutton.presentation.messages;
import org.bigbluebutton.api.messaging.messages.IMessage;
public class OfficeDocConversionProgress implements IDocConversionMsg {
public final String meetingId;
public final String presId;
public final String presInstance;
public final String filename;
public final String uploaderId;
public final String authzToken;
public final Boolean downloadable;
public final String key;
public OfficeDocConversionProgress(String meetingId, String presId, String presInstance,
String filename, String uploaderId, String authzToken,
Boolean downloadable, String key) {
this.meetingId = meetingId;
this.presId = presId;
this.presInstance = presInstance;
this.filename = filename;
this.uploaderId = uploaderId;
this.authzToken = authzToken;
this.downloadable = downloadable;
this.key = key;
}
}

View File

@ -0,0 +1,26 @@
package org.bigbluebutton.presentation.messages;
import org.bigbluebutton.api.messaging.messages.IMessage;
public class OfficeDocConversionSuccess implements IMessage{
public final String meetingId;
public final String presId;
public final String presInstance;
public final String filename;
public final String uploaderId;
public final String authzToken;
public final Boolean downloadable;
public OfficeDocConversionSuccess(String meetingId, String presId, String presInstance,
String filename, String uploaderId, String authzToken,
Boolean downloadable) {
this.meetingId = meetingId;
this.presId = presId;
this.presInstance = presInstance;
this.filename = filename;
this.uploaderId = uploaderId;
this.authzToken = authzToken;
this.downloadable = downloadable;
}
}

View File

@ -0,0 +1,26 @@
package org.bigbluebutton.presentation.messages;
import org.bigbluebutton.api.messaging.messages.IMessage;
public class OfficeDocConversionSupported implements IMessage{
public final String meetingId;
public final String presId;
public final String presInstance;
public final String filename;
public final String uploaderId;
public final String authzToken;
public final Boolean downloadable;
public OfficeDocConversionSupported(String meetingId, String presId, String presInstance,
String filename, String uploaderId, String authzToken,
Boolean downloadable) {
this.meetingId = meetingId;
this.presId = presId;
this.presInstance = presInstance;
this.filename = filename;
this.uploaderId = uploaderId;
this.authzToken = authzToken;
this.downloadable = downloadable;
}
}

View File

@ -0,0 +1,26 @@
package org.bigbluebutton.presentation.messages;
import org.bigbluebutton.api.messaging.messages.IMessage;
public class OfficeDocConversionUnsupported implements IMessage{
public final String meetingId;
public final String presId;
public final String presInstance;
public final String filename;
public final String uploaderId;
public final String authzToken;
public final Boolean downloadable;
public OfficeDocConversionUnsupported(String meetingId, String presId, String presInstance,
String filename, String uploaderId, String authzToken,
Boolean downloadable) {
this.meetingId = meetingId;
this.presId = presId;
this.presInstance = presInstance;
this.filename = filename;
this.uploaderId = uploaderId;
this.authzToken = authzToken;
this.downloadable = downloadable;
}
}

View File

@ -1,21 +1,20 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* 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
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
*/
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
* <p>
* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below).
* <p>
* 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
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
* <p>
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* <p>
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*/
package org.bigbluebutton.web.services;
@ -25,19 +24,17 @@ import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import org.bigbluebutton.api.messaging.MessageListener;
import org.bigbluebutton.api.messaging.MessagingService;
import org.bigbluebutton.api.messaging.messages.IMessage;
import org.bigbluebutton.api.messaging.messages.KeepAliveReply;
import org.bigbluebutton.api.pub.IPublisherService;
import org.bigbluebutton.api2.IBbbWebApiGWApp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class KeepAliveService implements MessageListener {
private static Logger log = LoggerFactory.getLogger(KeepAliveService.class);
private final String KEEP_ALIVE_REQUEST = "KEEP_ALIVE_REQUEST";
private MessagingService service;
private IBbbWebApiGWApp gw;
private long runEvery = 10000;
private int maxLives = 5;
private KeepAliveTask task = new KeepAliveTask();
@ -70,8 +67,8 @@ public class KeepAliveService implements MessageListener {
runEvery = v * 1000;
}
public void setPublisherService(MessagingService service){
this.service = service;
public void setGw(IBbbWebApiGWApp gw) {
this.gw = gw;
}
class KeepAliveTask implements Runnable {
@ -81,7 +78,7 @@ public class KeepAliveService implements MessageListener {
}
}
public boolean isDown(){
public boolean isDown() {
//return !available;
return false;
}
@ -115,9 +112,9 @@ public class KeepAliveService implements MessageListener {
Runnable task = new Runnable() {
public void run() {
if (msg instanceof KeepAlivePing) {
// processPing((KeepAlivePing) msg);
processPing((KeepAlivePing) msg);
} else if (msg instanceof KeepAlivePong) {
// processPong((KeepAlivePong) msg);
processPong((KeepAlivePong) msg);
}
}
};
@ -126,7 +123,7 @@ public class KeepAliveService implements MessageListener {
}
private void processPing(KeepAlivePing msg) {
service.sendKeepAlive(SYSTEM, System.currentTimeMillis());
gw.sendKeepAlive(SYSTEM, System.currentTimeMillis());
Boolean akkaAppsIsAvailable = available;
if (lastKeepAliveMessage != 0 && (System.currentTimeMillis() - lastKeepAliveMessage > 30000)) {
@ -152,7 +149,6 @@ public class KeepAliveService implements MessageListener {
KeepAlivePong pong = new KeepAlivePong(system, timestamp);
queueMessage(pong);
}
}
@Override

View File

@ -3,10 +3,13 @@ package org.bigbluebutton.api2
import scala.collection.JavaConverters._
import akka.actor.ActorSystem
import akka.event.Logging
import org.bigbluebutton.api.messaging.converters.messages._
import org.bigbluebutton.api2.bus._
import org.bigbluebutton.api2.endpoint.redis.{AppsRedisSubscriberActor, MessageSender, RedisPublisher}
import org.bigbluebutton.api2.meeting.{CreateMeetingMsg, MeetingsManagerActor, RegisterUser}
import org.bigbluebutton.api2.meeting.{MeetingsManagerActor, OldMeetingMsgHdlrActor, RegisterUser}
import org.bigbluebutton.common.messages.SendStunTurnInfoReplyMessage
import org.bigbluebutton.common2.domain._
import org.bigbluebutton.presentation.messages.IDocConversionMsg
import scala.concurrent.duration._
@ -24,8 +27,7 @@ class BbbWebApiGWApp(val oldMessageReceivedGW: OldMessageReceivedGW) extends IBb
private val jsonMsgToAkkaAppsBus = new JsonMsgToAkkaAppsBus
private val redisPublisher = new RedisPublisher(system)
private val msgSender: MessageSender = new MessageSender(redisPublisher)
private val messageSenderActorRef = system.actorOf(
MessageSenderActor.props(msgSender), "messageSenderActor")
private val messageSenderActorRef = system.actorOf(MessageSenderActor.props(msgSender), "messageSenderActor")
jsonMsgToAkkaAppsBus.subscribe(messageSenderActorRef, toAkkaAppsJsonChannel)
@ -38,6 +40,11 @@ class BbbWebApiGWApp(val oldMessageReceivedGW: OldMessageReceivedGW) extends IBb
MeetingsManagerActor.props(msgToAkkaAppsEventBus), "meetingManagerActor")
msgFromAkkaAppsEventBus.subscribe(meetingManagerActorRef, fromAkkaAppsChannel)
private val oldMeetingMsgHdlrActor = system.actorOf(
OldMeetingMsgHdlrActor.props(oldMessageReceivedGW), "oldMeetingMsgHdlrActor"
)
msgFromAkkaAppsEventBus.subscribe(oldMeetingMsgHdlrActor, fromAkkaAppsChannel)
private val msgToAkkaAppsToJsonActor = system.actorOf(
MsgToAkkaAppsToJsonActor.props(jsonMsgToAkkaAppsBus), "msgToAkkaAppsToJsonActor")
@ -94,14 +101,58 @@ class BbbWebApiGWApp(val oldMessageReceivedGW: OldMessageReceivedGW) extends IBb
val defaultProps = DefaultProps(meetingProp, breakoutProps, durationProps, password, recordProp, welcomeProp, voiceProp,
usersProp, metadataProp, screenshareProps)
meetingManagerActorRef ! new CreateMeetingMsg(defaultProps)
//meetingManagerActorRef ! new CreateMeetingMsg(defaultProps)
val event = MsgBuilder.buildCreateMeetingRequestToAkkaApps(defaultProps)
msgToAkkaAppsEventBus.publish(MsgToAkkaApps(toAkkaAppsChannel, event))
}
def registerUser (meetingId: String, intUserId: String, name: String,
role: String, extUserId: String, authToken: String, avatarURL: String,
guest: java.lang.Boolean, authed: java.lang.Boolean): Unit = {
meetingManagerActorRef ! new RegisterUser(meetingId = meetingId, intUserId = intUserId, name = name,
// meetingManagerActorRef ! new RegisterUser(meetingId = meetingId, intUserId = intUserId, name = name,
// role = role, extUserId = extUserId, authToken = authToken, avatarURL = avatarURL,
// guest = guest, authed = authed)
val regUser = new RegisterUser(meetingId = meetingId, intUserId = intUserId, name = name,
role = role, extUserId = extUserId, authToken = authToken, avatarURL = avatarURL,
guest = guest, authed = authed)
guest = guest.booleanValue(), authed = authed.booleanValue())
val event = MsgBuilder.buildRegisterUserRequestToAkkaApps(regUser)
msgToAkkaAppsEventBus.publish(MsgToAkkaApps(toAkkaAppsChannel, event))
}
def destroyMeeting (msg: DestroyMeetingMessage): Unit = {
}
def endMeeting(msg: EndMeetingMessage): Unit = {
}
def sendKeepAlive(system: String, timestamp: java.lang.Long): Unit = {
}
def publishRecording(msg: PublishRecordingMessage): Unit = {
}
def unpublishRecording(msg: UnpublishRecordingMessage): Unit = {
}
def deleteRecording(msg: DeleteRecordingMessage): Unit = {
}
def sendStunTurnInfoReply(msg: SendStunTurnInfoReplyMessage): Unit = {
}
def sendDocConversionMsg(msg: IDocConversionMsg): Unit = {
}
}

View File

@ -0,0 +1,29 @@
package org.bigbluebutton.api2
import org.bigbluebutton.api2.meeting.RegisterUser
import org.bigbluebutton.common2.domain.DefaultProps
import org.bigbluebutton.common2.msgs._
object MsgBuilder {
def buildCreateMeetingRequestToAkkaApps(props: DefaultProps): BbbCommonEnvCoreMsg = {
val routing = collection.immutable.HashMap("sender" -> "bbb-web")
val envelope = BbbCoreEnvelope(CreateMeetingReqMsg.NAME, routing)
val header = BbbCoreBaseHeader(CreateMeetingReqMsg.NAME)
val body = CreateMeetingReqMsgBody(props)
val req = CreateMeetingReqMsg(header, body)
BbbCommonEnvCoreMsg(envelope, req)
}
def buildRegisterUserRequestToAkkaApps(msg: RegisterUser): BbbCommonEnvCoreMsg = {
val routing = collection.immutable.HashMap("sender" -> "bbb-web")
val envelope = BbbCoreEnvelope(RegisterUserReqMsg.NAME, routing)
val header = BbbCoreHeaderWithMeetingId(RegisterUserReqMsg.NAME, msg.meetingId)
val body = RegisterUserReqMsgBody(meetingId = msg.meetingId, intUserId = msg.intUserId,
name = msg.name, role = msg.role, extUserId = msg.extUserId, authToken = msg.authToken,
avatarURL = msg.avatarURL, guest = msg.guest, authed = msg.authed)
val req = RegisterUserReqMsg(header, body)
BbbCommonEnvCoreMsg(envelope, req)
}
}

View File

@ -9,6 +9,6 @@ object OldMessageJsonReceiverActor{
class OldMessageJsonReceiverActor(gw: OldMessageReceivedGW) extends Actor with ActorLogging {
def receive = {
case msg: OldReceivedJsonMessage => gw.handle(msg.pattern, msg.channel, msg.msg)
case msg: OldReceivedJsonMessage => //gw.handle(msg.pattern, msg.channel, msg.msg)
}
}

View File

@ -1,11 +1,13 @@
package org.bigbluebutton.api2.bus
import org.bigbluebutton.api.IReceivedOldMessageHandler
import org.bigbluebutton.api.messaging.messages.IMessage
class OldMessageReceivedGW(handler: IReceivedOldMessageHandler) {
def handle(pattern: String, channel: String, msg: String): Unit = {
handler.handleMessage(pattern, channel, msg)
def handle(msg: IMessage): Unit = {
handler.handleMessage(msg)
}
}

View File

@ -0,0 +1,103 @@
package org.bigbluebutton.api2.meeting
import akka.actor.{Actor, ActorLogging, Props}
import org.bigbluebutton.api2.bus.OldMessageReceivedGW
import org.bigbluebutton.common2.msgs._
object OldMeetingMsgHdlrActor {
def props(olgMsgGW: OldMessageReceivedGW): Props =
Props(classOf[OldMeetingMsgHdlrActor], olgMsgGW)
}
class OldMeetingMsgHdlrActor(val olgMsgGW: OldMessageReceivedGW)
extends Actor with ActorLogging {
def receive = {
case msg: BbbCommonEnvCoreMsg => handleBbbCommonEnvCoreMsg(msg)
}
private def handleBbbCommonEnvCoreMsg(msg: BbbCommonEnvCoreMsg): Unit = {
msg.core match {
case m: MeetingCreatedEvtMsg => handleMeetingCreatedEvtMsg(m)
case _ => log.error("***** Cannot handle " + msg.envelope.name)
}
}
def handleMeetingCreatedEvtMsg(msg: MeetingCreatedEvtMsg): Unit = {
// listener.handle(new MeetingStarted(meetingId))
}
def handleMeetingEndedEvtMsg(msg: MeetingEndedEvtMsg): Unit = {
// listener.handle(new MeetingEnded(meetingId))
}
def handleMeetingDestroyedEvtMsg(msg: MeetingDestroyedEvtMsg): Unit = {
// listener.handle(new MeetingDestroyed(meetingId))
}
// def handleCreateBreakoutRoomSysCmdMsg(msg: CreateBreakoutRoomSysCmdMsg): Unit = {
/* listener.handle(new CreateBreakoutRoom(
msg.payload.breakoutMeetingId,
msg.payload.parentMeetingId,
msg.payload.name,
msg.payload.sequence,
msg.payload.voiceConfId,
msg.payload.viewerPassword,
msg.payload.moderatorPassword,
msg.payload.durationInMinutes,
msg.payload.sourcePresentationId,
msg.payload.sourcePresentationSlide,
msg.payload.record
)
);
*/
// }
// def handleEndBreakoutRoomSysCmdMsg(msg: EndBreakoutRoomSysCmdMsg): Unit = {
//listener.handle(new EndBreakoutRoom(msg.payload.meetingId))
// }
// def handlePubSubPongSysRespMsg(msg: PubSubPongSysRespMsg): Unit = {
// new KeepAliveReply(m.payload.system, m.payload.timestamp)
// }
// def handleUserJoinedMeetingEvtMsg(msg: UserJoinedMeetingEvtMsg): Unit = {
// listener.handle(new UserJoined(meetingId, userid, externuserid, username, role, avatarURL, guest, waitingForAcceptance));
// }
// def handleUserStausChangedEvtMsg(msg: UserStatusChangedEvtMsg): Unit = {
//listener.handle(new UserStatusChanged(meetingId, userid, status, value))
// }
// def handleUserLeftMeetingEvtMsg(msg: UserLeftMeetingEvtMsg): Unit = {
// listener.handle(new UserLeft(meetingId, userid))
// }
/**
* for (MessageListener listener : listeners) {
listener.handle(new UserJoinedVoice(meetingId, userid));
}
for (MessageListener listener : listeners) {
listener.handle(new UserLeftVoice(meetingId, userid));
}
for (MessageListener listener : listeners) {
listener.handle(new UserListeningOnly(meetingId, userid, listenOnly));
}
for (MessageListener listener : listeners) {
listener.handle(new UserSharedWebcam(meetingId, userid, stream));
}
for (MessageListener listener : listeners) {
listener.handle(new UserUnsharedWebcam(meetingId, userid, stream));
}
for (MessageListener listener : listeners) {
listener.handle(new UserRoleChanged(meetingId, userid, role));
}
for (MessageListener listener : listeners) {
listener.handle(new StunTurnInfoRequested(meetingId, requesterId));
}
*/
}

View File

@ -27,34 +27,6 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
http://www.springframework.org/schema/util/spring-util-2.0.xsd
">
<bean id="redisStorageService" class="org.bigbluebutton.api.messaging.RedisStorageService"
init-method="start" destroy-method="stop">
<property name="host" value="${redisHost}" />
<property name="port" value="${redisPort}" />
</bean>
<bean id="redisMessageHandler" class="org.bigbluebutton.api.messaging.ReceivedMessageHandler"
init-method="start" destroy-method="stop">
<property name="messageDistributor"><ref bean="redisMessageDistributor" /></property>
</bean>
<bean id="redisMessageDistributor" class="org.bigbluebutton.api.messaging.MessageDistributor">
<property name="messageHandler"> <ref local="redisMessageHandler"/> </property>
<property name="messageListeners">
<set>
<ref bean="meetingMessageHandler" />
</set>
</property>
</bean>
<bean id="meetingMessageHandler" class="org.bigbluebutton.api.messaging.MeetingMessageHandler">
<property name="messageListeners">
<set>
<ref bean="meetingService" />
<ref bean="keepAliveService" />
</set>
</property>
</bean>
</beans>

View File

@ -24,7 +24,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="documentConversionService" class="org.bigbluebutton.presentation.DocumentConversionServiceImp">
<property name="messagingService" ref="messagingService"/>
<property name="bbbWebApiGWApp" ref="bbbWebApiGWApp"/>
<property name="officeToPdfConversionService" ref="officeToPdfConversionService"/>
<property name="pdfToSwfSlidesGenerationService" ref="pdfToSwfSlidesGenerationService"/>
<property name="imageToSwfSlidesGenerationService" ref="imageToSwfSlidesGenerationService"/>
@ -74,7 +74,8 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<bean id="generatedSlidesInfoHelper" class="org.bigbluebutton.presentation.GeneratedSlidesInfoHelperImp"/>
<bean id="pdfToSwfSlidesGenerationService" class="org.bigbluebutton.presentation.imp.PdfToSwfSlidesGenerationService">
<bean id="pdfToSwfSlidesGenerationService"
class="org.bigbluebutton.presentation.imp.PdfToSwfSlidesGenerationService">
<constructor-arg index="0" value="${numConversionThreads}"/>
<property name="counterService" ref="pageCounterService"/>
<property name="pageConverter" ref="pdf2SwfPageConverter"/>
@ -88,7 +89,8 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<property name="svgImagesRequired" value="${svgImagesRequired}"/>
</bean>
<bean id="imageToSwfSlidesGenerationService" class="org.bigbluebutton.presentation.imp.ImageToSwfSlidesGenerationService">
<bean id="imageToSwfSlidesGenerationService"
class="org.bigbluebutton.presentation.imp.ImageToSwfSlidesGenerationService">
<property name="pngPageConverter" ref="png2SwfConverter"/>
<property name="jpgPageConverter" ref="jpg2SwfConverter"/>
<property name="svgImageCreator" ref="svgImageCreator"/>
@ -99,8 +101,9 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<property name="swfSlidesGenerationProgressNotifier" ref="swfSlidesGenerationProgressNotifier"/>
</bean>
<bean id="swfSlidesGenerationProgressNotifier" class="org.bigbluebutton.presentation.imp.SwfSlidesGenerationProgressNotifier">
<property name="messagingService" ref="messagingService"/>
<bean id="swfSlidesGenerationProgressNotifier"
class="org.bigbluebutton.presentation.imp.SwfSlidesGenerationProgressNotifier">
<property name="messagingService" ref="bbbWebApiGWApp"/>
<property name="generatedSlidesInfoHelper" ref="generatedSlidesInfoHelper"/>
</bean>
</beans>

View File

@ -26,31 +26,23 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.0.xsd">
<bean id="messagingService" class="org.bigbluebutton.api.messaging.RedisMessagingService">
<property name="messageSender" ref="messageSender"/>
<property name="redisStorageService" ref="redisStorageService"/>
</bean>
<bean id="messageSender" class="org.bigbluebutton.api.messaging.MessageSender">
<property name="gw" ref="bbbWebApiGWApp" />
</bean>
<bean id="registeredUserCleanupTimerTask" class="org.bigbluebutton.web.services.RegisteredUserCleanupTimerTask"/>
<bean id="keepAliveService" class="org.bigbluebutton.web.services.KeepAliveService"
init-method="start" destroy-method="stop">
<property name="runEvery" value="${checkBBBServerEvery}"/>
<property name="publisherService" ref="messagingService" />
<property name="gw" ref="bbbWebApiGWApp"/>
</bean>
<bean id="meetingService" class="org.bigbluebutton.api.MeetingService" init-method="start" destroy-method="stop">
<property name="messagingService" ref="messagingService"/>
<property name="redisStorageService" ref="redisStorageService"/>
<property name="recordingService" ref="recordingService"/>
<property name="presDownloadService" ref="presDownloadService"/>
<property name="paramsProcessorUtil" ref="paramsProcessorUtil"/>
<property name="stunTurnService" ref="stunTurnService"/>
<property name="registeredUserCleanupTimerTask" ref="registeredUserCleanupTimerTask"/>
<property name="gw" ref="bbbWebApiGWApp" />
<property name="gw" ref="bbbWebApiGWApp"/>
</bean>
<bean id="oldMessageReceivedGW" class="org.bigbluebutton.api2.bus.OldMessageReceivedGW">
@ -61,9 +53,32 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<constructor-arg index="0" ref="oldMessageReceivedGW"/>
</bean>
<bean id="redisStorageService" class="org.bigbluebutton.api.messaging.RedisStorageService"
init-method="start" destroy-method="stop">
<property name="host" value="${redisHost}"/>
<property name="port" value="${redisPort}"/>
</bean>
<bean id="redisMessageHandler" class="org.bigbluebutton.api.messaging.ReceivedMessageHandler"
init-method="start" destroy-method="stop">
</bean>
<bean id="redisMessageDistributor" class="org.bigbluebutton.api.messaging.MessageDistributor">
<property name="messageHandler"> <ref local="redisMessageHandler"/> </property>
<property name="messageListeners">
<set>
<ref bean="meetingService" />
<ref bean="keepAliveService" />
</set>
</property>
</bean>
<bean id="recordingServiceHelper" class="org.bigbluebutton.api.RecordingServiceHelperImp"/>
<bean id="presDownloadService" class="org.bigbluebutton.presentation.PresentationUrlDownloadService" destroy-method="stop">
<bean id="presDownloadService" class="org.bigbluebutton.presentation.PresentationUrlDownloadService"
destroy-method="stop">
<property name="presentationDir" value="${presentationDir}"/>
<property name="presentationBaseURL" value="${presentationBaseURL}"/>
<property name="pageExtractor" ref="pageExtractor"/>
@ -71,12 +86,11 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<property name="blankPresentation" value="${BLANK_PRESENTATION}"/>
</bean>
<bean id="recordingService" class="org.bigbluebutton.api.RecordingService" >
<bean id="recordingService" class="org.bigbluebutton.api.RecordingService">
<property name="recordingStatusDir" value="${recordStatusDir}"/>
<property name="publishedDir" value="${publishedDir}"/>
<property name="unpublishedDir" value="${unpublishedDir}"/>
<property name="recordingServiceHelper" ref="recordingServiceHelper"/>
<!--property name="messagingService" ref="messagingService"/-->
</bean>
<bean id="configServiceHelper" class="org.bigbluebutton.api.ClientConfigServiceHelperImp"/>
@ -110,8 +124,10 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<property name="defaultGuestPolicy" value="${defaultGuestPolicy}"/>
</bean>
<import resource="doc-conversion.xml" />
<import resource="bbb-redis-pool.xml" />
<import resource="bbb-redis-messaging.xml" />
<import resource="turn-stun-servers.xml" />
<import resource="doc-conversion.xml"/>
<import resource="bbb-redis-pool.xml"/>
<!--
<import resource="bbb-redis-messaging.xml"/>
-->
<import resource="turn-stun-servers.xml"/>
</beans>