- make sure create, register user and validate are in correct sequence

This commit is contained in:
Richard Alam 2014-05-21 13:56:37 -07:00
parent f266067e1a
commit 4a4241ee78
5 changed files with 52 additions and 9 deletions

View File

@ -47,7 +47,14 @@ class BigBlueButtonActor(outGW: MessageOutGateway) extends Actor {
private def handleMeetingNotFound(msg: InMessage) {
msg match {
case vat:ValidateAuthToken => outGW.send(new ValidateAuthTokenReply(vat.meetingID, vat.userId, vat.token, false, vat.correlationId))
case vat:ValidateAuthToken => {
println("No meeting [" + vat.meetingID + "] for auth token [" + vat.token + "]")
outGW.send(new ValidateAuthTokenReply(vat.meetingID, vat.userId, vat.token, false, vat.correlationId))
}
case _ => {
println("No meeting [" + msg.meetingID + "] for message type [" + msg.getClass() + "]")
// do nothing
}
}
}
@ -74,6 +81,7 @@ class BigBlueButtonActor(outGW: MessageOutGateway) extends Actor {
private def handleCreateMeeting(msg: CreateMeeting):Unit = {
meetings.get(msg.meetingID) match {
case None => {
println("New meeting create request [" + msg.meetingName + "]")
var m = new MeetingActor(msg.meetingID, msg.meetingName, msg.recorded, msg.voiceBridge, msg.duration, outGW)
m.start
meetings += m.meetingID -> m
@ -82,7 +90,10 @@ class BigBlueButtonActor(outGW: MessageOutGateway) extends Actor {
m ! new InitializeMeeting(m.meetingID, m.recorded)
m ! "StartTimer"
}
case Some(m) => // do nothing
case Some(m) => {
println("Meeting already created [" + msg.meetingName + "]")
// do nothing
}
}
}

View File

@ -44,6 +44,7 @@ import org.bigbluebutton.api.messaging.messages.IMessage;
import org.bigbluebutton.api.messaging.messages.MeetingDestroyed;
import org.bigbluebutton.api.messaging.messages.MeetingEnded;
import org.bigbluebutton.api.messaging.messages.MeetingStarted;
import org.bigbluebutton.api.messaging.messages.RegisterUser;
import org.bigbluebutton.api.messaging.messages.RemoveExpiredMeetings;
import org.bigbluebutton.api.messaging.messages.UserJoined;
import org.bigbluebutton.api.messaging.messages.UserLeft;
@ -81,7 +82,7 @@ public class MeetingService implements MessageListener {
}
public void registerUser(String meetingID, String internalUserId, String fullname, String role, String externUserID, String authToken) {
messagingService.registerUser(meetingID, internalUserId, fullname, role, externUserID, authToken);
handle(new RegisterUser(meetingID, internalUserId, fullname, role, externUserID, authToken));
}
public UserSession getUserSession(String token) {
@ -161,6 +162,7 @@ public class MeetingService implements MessageListener {
private void handleCreateMeeting(Meeting m) {
log.debug("Storing Meeting with internal id:" + m.getInternalId());
System.out.println(" ******************* Storing Meeting with internal id:" + m.getInternalId());
meetings.put(m.getInternalId(), m);
if (m.isRecord()) {
Map<String,String> metadata = new LinkedHashMap<String,String>();
@ -179,6 +181,10 @@ public class MeetingService implements MessageListener {
handleCreateMeeting(message.meeting);
}
private void processRegisterUser(RegisterUser message) {
messagingService.registerUser(message.meetingID, message.internalUserId, message.fullname, message.role, message.externUserID, message.authToken);
}
public String addSubscription(String meetingId, String event, String callbackURL){
log.debug("Add a new subscriber");
String sid = messagingService.storeSubscription(meetingId, event, callbackURL);
@ -416,6 +422,8 @@ public class MeetingService implements MessageListener {
} else if (message instanceof EndMeeting) {
log.info("Processing end meeting request.");
processEndMeeting((EndMeeting)message);
} else if (message instanceof RegisterUser) {
processRegisterUser((RegisterUser) message);
}
}
@ -443,7 +451,9 @@ public class MeetingService implements MessageListener {
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (Exception e) {
log.error("Handling unexpected exception [{}]", e.toString());
}
}
}
};

View File

@ -27,9 +27,7 @@ import java.util.List;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import javax.imageio.ImageIO;
import org.bigbluebutton.api.messaging.converters.messages.CreateMeetingMessage;
import org.bigbluebutton.api.messaging.converters.messages.DestroyMeetingMessage;
import org.bigbluebutton.api.messaging.converters.messages.EndMeetingMessage;
@ -37,10 +35,8 @@ import org.bigbluebutton.api.messaging.converters.messages.KeepAliveMessage;
import org.bigbluebutton.api.messaging.converters.messages.RegisterUserMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPubSub;
@ -58,24 +54,28 @@ public class RedisMessagingService implements MessagingService {
public void destroyMeeting(String meetingID) {
DestroyMeetingMessage msg = new DestroyMeetingMessage(meetingID);
String json = MessageToJson.destroyMeetingMessageToJson(msg);
log.info("Sending destory meeting message to bbb-apps:[{}]", json);
sender.send(MessagingConstants.TO_MEETING_CHANNEL, json);
}
public void registerUser(String meetingID, String internalUserId, String fullname, String role, String externUserID, String authToken) {
RegisterUserMessage msg = new RegisterUserMessage(meetingID, internalUserId, fullname, role, externUserID, authToken);
String json = MessageToJson.registerUserToJson(msg);
log.info("Sending register user message to bbb-apps:[{}]", json);
sender.send(MessagingConstants.TO_MEETING_CHANNEL, json);
}
public void createMeeting(String meetingID, String meetingName, Boolean recorded, String voiceBridge, Long duration) {
CreateMeetingMessage msg = new CreateMeetingMessage(meetingID, meetingName, recorded, voiceBridge, duration);
String json = MessageToJson.createMeetingMessageToJson(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);
}

View File

@ -0,0 +1,20 @@
package org.bigbluebutton.api.messaging.messages;
public class RegisterUser implements IMessage {
public final String meetingID;
public final String internalUserId;
public final String fullname;
public final String role;
public final String externUserID;
public final String authToken;
public RegisterUser(String meetingID, String internalUserId, String fullname, String role, String externUserID, String authToken) {
this.meetingID = meetingID;
this.internalUserId = internalUserId;
this.fullname = fullname;
this.role = role;
this.externUserID = externUserID;
this.authToken = authToken;
}
}

View File

@ -110,7 +110,9 @@ public class KeepAliveService implements MessageListener {
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (Exception e) {
log.error("Catching exception [{}]", e.toString());
}
}
}
};