Skip to content

Commit

Permalink
- try to fix auto-reconnect for listen only users
Browse files Browse the repository at this point in the history
  • Loading branch information
ritzalam committed Sep 3, 2015
1 parent ddc726a commit 52d2ed1
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 57 deletions.
2 changes: 1 addition & 1 deletion akka-bbb-apps/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%date{ISO8601} %-5level %logger{36} %X{akkaSource} - %msg%n</pattern>
<pattern>%date{ISO8601} %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,8 @@ class BigBlueButtonInGW(val system: ActorSystem, recorderApp: RecorderApplicatio
def voiceUserJoined(voiceConfId: String, voiceUserId: String, userId: String, callerIdName: String,
callerIdNum: String, muted: java.lang.Boolean, talking: java.lang.Boolean) {

bbbActor ! new UserJoinedVoiceConfMessage(voiceConfId, voiceUserId, userId, callerIdName,
callerIdNum, muted, talking)
bbbActor ! new UserJoinedVoiceConfMessage(voiceConfId, voiceUserId, userId, userId, callerIdName,
callerIdNum, muted, talking, false /*hardcode listenOnly to false as the message for listenOnly is ConnectedToGlobalAudio*/ )

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ case class LockUserRequest(meetingID: String, requesterID: String, userID: Strin
case class EjectUserFromVoiceRequest(meetingID: String, userId: String, ejectedBy: String) extends InMessage
case class VoiceUserJoinedMessage(meetingID: String, user: String, voiceConfId: String,
callerIdNum: String, callerIdName: String, muted: Boolean, talking: Boolean) extends InMessage
case class UserJoinedVoiceConfMessage(voiceConfId: String, voiceUserId: String, userId: String,
callerIdName: String, callerIdNum: String, muted: Boolean, talking: Boolean)
case class UserJoinedVoiceConfMessage(voiceConfId: String, voiceUserId: String, userId: String, externUserId: String,
callerIdName: String, callerIdNum: String, muted: Boolean, talking: Boolean, listenOnly: Boolean)
case class UserLeftVoiceConfMessage(voiceConfId: String, voiceUserId: String)
case class UserLockedInVoiceConfMessage(voiceConfId: String, voiceUserId: String, locked: Boolean)
case class UserMutedInVoiceConfMessage(voiceConfId: String, voiceUserId: String, muted: Boolean)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ case class UserVO(
webcamStreams: Set[String],
phoneUser: Boolean,
voiceUser: VoiceUser,
listenOnly: Boolean)
listenOnly: Boolean,
joinedWeb: Boolean)

case class VoiceUser(
userId: String,
Expand All @@ -103,7 +104,8 @@ case class VoiceUser(
joined: Boolean,
locked: Boolean,
muted: Boolean,
talking: Boolean)
talking: Boolean,
listenOnly: Boolean)

case class MeetingConfig(name: String,
id: MeetingID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ trait UsersApp {
}

def handleUserConnectedToGlobalAudio(msg: UserConnectedToGlobalAudio) {
log.info("Handling UserConnectedToGlobalAudio: mid=[" + mProps.meetingID + "] uid=[" + msg.userid + "]")

val user = usersModel.getUserWithExternalId(msg.userid)
user foreach { u =>
val vu = u.voiceUser.copy(talking = false)
Expand All @@ -33,12 +35,20 @@ trait UsersApp {
}

def handleUserDisconnectedFromGlobalAudio(msg: UserDisconnectedFromGlobalAudio) {
log.info("Handling UserDisconnectedToGlobalAudio: mid=[" + mProps.meetingID + "] uid=[" + msg.userid + "]")

val user = usersModel.getUserWithExternalId(msg.userid)
user foreach { u =>
val uvo = u.copy(listenOnly = false)
usersModel.addUser(uvo)
log.info("UserDisconnectedToGlobalAudio: mid=[" + mProps.meetingID + "] uid=[" + uvo.userID + "]")
outGW.send(new UserListeningOnly(mProps.meetingID, mProps.recorded, uvo.userID, uvo.listenOnly))
if (!u.joinedWeb) {
val userLeaving = usersModel.removeUser(u.userID)
userLeaving foreach (u => outGW.send(new UserLeft(mProps.meetingID, mProps.recorded, u)))
} else {
val uvo = u.copy(listenOnly = false)
usersModel.addUser(uvo)
log.info("UserDisconnectedToGlobalAudio: mid=[" + mProps.meetingID + "] uid=[" + uvo.userID + "]")
outGW.send(new UserListeningOnly(mProps.meetingID, mProps.recorded, uvo.userID, uvo.listenOnly))
}

}
}

Expand Down Expand Up @@ -267,23 +277,23 @@ trait UsersApp {
val regUser = usersModel.getRegisteredUserWithToken(msg.authToken)
regUser foreach { ru =>
// if there was a phoneUser with the same userID, reuse the VoiceUser value object
val vu = usersModel.getUser(msg.userID) match {
val vu = usersModel.getUserWithExternalId(ru.externId) match {
case Some(u) => {
if (u.voiceUser.joined) {
u.voiceUser.copy()
} else {
new VoiceUser(msg.userID, msg.userID, ru.name, ru.name, false, false, false, false)
new VoiceUser(msg.userID, msg.userID, ru.name, ru.name, false, false, false, false, u.listenOnly)
}
}
case None => {
new VoiceUser(msg.userID, msg.userID, ru.name, ru.name, false, false, false, false)
new VoiceUser(msg.userID, msg.userID, ru.name, ru.name, false, false, false, false, false)
}
}

val uvo = new UserVO(msg.userID, ru.externId, ru.name,
ru.role, emojiStatus = "none", presenter = false,
hasStream = false, locked = getInitialLockStatus(ru.role),
webcamStreams = new ListSet[String](), phoneUser = false, vu, listenOnly = false)
webcamStreams = new ListSet[String](), phoneUser = false, vu, listenOnly = vu.listenOnly, true)

usersModel.addUser(uvo)

Expand Down Expand Up @@ -326,8 +336,8 @@ trait UsersApp {
}
// add VoiceUser again to the list as a phone user since we still didn't get the event from FreeSWITCH
val vu = u.voiceUser
if (vu.joined) {
this.context.self ! (new UserJoinedVoiceConfMessage(mProps.voiceBridge, vu.userId, msg.userID, vu.callerName, vu.callerNum, vu.muted, vu.talking));
if (vu.joined || u.listenOnly) {
this.context.self ! (new UserJoinedVoiceConfMessage(mProps.voiceBridge, vu.userId, u.userID, u.externUserID, vu.callerName, vu.callerNum, vu.muted, vu.talking, u.listenOnly));
}
}

Expand Down Expand Up @@ -355,22 +365,23 @@ trait UsersApp {
usersModel.generateWebUserId
}
val vu = new VoiceUser(msg.voiceUserId, webUserId, msg.callerIdName, msg.callerIdNum,
true, false, msg.muted, msg.talking)
true, false, msg.muted, msg.talking, msg.listenOnly)

val sessionId = "PHONE-" + webUserId;

val uvo = new UserVO(webUserId, webUserId, msg.callerIdName,
val uvo = new UserVO(webUserId, msg.externUserId, msg.callerIdName,
Role.VIEWER, emojiStatus = "none", presenter = false,
hasStream = false, locked = getInitialLockStatus(Role.VIEWER), webcamStreams = new ListSet[String](),
phoneUser = true, vu, listenOnly = false)
phoneUser = true, vu, listenOnly = msg.listenOnly, false)

usersModel.addUser(uvo)
log.info("New user joined voice for user [" + uvo.name + "] userid=[" + webUserId + "]")
outGW.send(new UserJoined(mProps.meetingID, mProps.recorded, uvo))

outGW.send(new UserJoinedVoice(mProps.meetingID, mProps.recorded, mProps.voiceBridge, uvo))
if (meetingModel.isMeetingMuted())
if (meetingModel.isMeetingMuted()) {
outGW.send(new MuteVoiceUser(mProps.meetingID, mProps.recorded, uvo.userID, uvo.userID, mProps.voiceBridge, vu.userId, meetingModel.isMeetingMuted()))
}

}
}
Expand All @@ -386,10 +397,10 @@ trait UsersApp {
def handleUserJoinedVoiceConfMessage(msg: UserJoinedVoiceConfMessage) = {
log.info("Received user joined voice for user [" + msg.callerIdName + "] userid=[" + msg.userId + "]")

usersModel.getUserWithExternalId(msg.userId) match {
usersModel.getUserWithExternalId(msg.externUserId) match {
case Some(user) => {
val vu = new VoiceUser(msg.voiceUserId, msg.userId, msg.callerIdName, msg.callerIdNum, true, false, msg.muted, msg.talking)
val nu = user.copy(voiceUser = vu)
val vu = new VoiceUser(msg.voiceUserId, msg.userId, msg.callerIdName, msg.callerIdNum, true, false, msg.muted, msg.talking, msg.listenOnly)
val nu = user.copy(voiceUser = vu, listenOnly = msg.listenOnly)
usersModel.addUser(nu)
log.info("User joined voice for user [" + nu.name + "] userid=[" + msg.userId + "]")
outGW.send(new UserJoinedVoice(mProps.meetingID, mProps.recorded, mProps.voiceBridge, nu))
Expand All @@ -416,7 +427,7 @@ trait UsersApp {

def handleUserLeftVoiceConfMessage(msg: UserLeftVoiceConfMessage) {
usersModel.getUserWithVoiceUserId(msg.voiceUserId) foreach { user =>
val vu = new VoiceUser(user.userID, user.userID, user.name, user.name, false, false, false, false)
val vu = new VoiceUser(user.userID, user.userID, user.name, user.name, false, false, false, false, false)
val nu = user.copy(voiceUser = vu)
usersModel.addUser(nu)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ public void userConnectedToGlobalAudio(String voiceConf, String callerIdName) {

@Override
public void userDisconnectedFromGlobalAudio(String voiceConf, String callerIdName) {
Matcher matcher = CALLERNAME_PATTERN.matcher(callerIdName);
if (matcher.matches()) {
String userid = matcher.group(1).trim();
String name = matcher.group(2).trim();
String json = new UserDisconnectedFromGlobalAudio(voiceConf, userid, name).toJson();
sender.send(MessagingConstants.TO_MEETING_CHANNEL, json);
} else {
log.warn("Invalid calleridname [{}] in userDisconnectedFromGlobalAudio as it does not match pattern (.*)-bbbID-(.*)");
String json = new UserDisconnectedFromGlobalAudio(voiceConf, callerIdName, callerIdName).toJson();
sender.send(MessagingConstants.TO_MEETING_CHANNEL, json);
}
Matcher matcher = CALLERNAME_PATTERN.matcher(callerIdName);
if (matcher.matches()) {
String userid = matcher.group(1).trim();
String name = matcher.group(2).trim();
String json = new UserDisconnectedFromGlobalAudio(voiceConf, userid, name).toJson();
sender.send(MessagingConstants.TO_MEETING_CHANNEL, json);
} else {
log.warn("Invalid calleridname [{}] in userDisconnectedFromGlobalAudio as it does not match pattern (.*)-bbbID-(.*)");
String json = new UserDisconnectedFromGlobalAudio(voiceConf, callerIdName, callerIdName).toJson();
sender.send(MessagingConstants.TO_MEETING_CHANNEL, json);
}
}

public void setRedisMessageSender(MessageSender sender) {
Expand Down
1 change: 1 addition & 0 deletions bbb-voice/src/main/java/org/bigbluebutton/voiceconf/sip/SipPeer.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public void hangup(String clientId) {

if (ca != null) {
if (ca.isListeningToGlobal()) {
log.debug("User is in listen only mode.");
String destination = ca.getDestination();
ListenOnlyUser lou = GlobalCall.removeUser(clientId, destination);
if (lou != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The ip and port the BBB SIP app is going to use
bbb.sip.app.ip=127.0.0.1
bbb.sip.app.ip=192.168.23.44
bbb.sip.app.port=5070

# The username and password the BBB SIP app to use to
Expand All @@ -9,7 +9,7 @@ sip.server.password=secret


# The ip and port of the FreeSWITCH server
freeswitch.ip=127.0.0.1
freeswitch.ip=192.168.23.44
freeswitch.port=5060

# The start/stop RTP port the application is going to use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ package org.bigbluebutton.core.managers

public class ReconnectionManager
{
private static const LOGGER:ILogger = getClassLogger(AutoReconnect);
private static const LOGGER:ILogger = getClassLogger(ReconnectionManager);

public static const BIGBLUEBUTTON_CONNECTION:String = "BIGBLUEBUTTON_CONNECTION";
public static const SIP_CONNECTION:String = "SIP_CONNECTION";
Expand All @@ -53,7 +53,7 @@ package org.bigbluebutton.core.managers
private var _connections:Dictionary = new Dictionary();
private var _reestablished:ArrayCollection = new ArrayCollection();
private var _reconnectTimer:Timer = new Timer(10000, 1);
private var _reconnectTimeout:Timer = new Timer(5000, 1);
private var _reconnectTimeout:Timer = new Timer(15000, 1);
private var _dispatcher:Dispatcher = new Dispatcher();
private var _popup:IFlexDisplayObject = null;
private var _canceled:Boolean = false;
Expand Down
22 changes: 5 additions & 17 deletions bigbluebutton-client/src/org/bigbluebutton/main/model/users/NetConnectionDelegate.as
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,7 @@ package org.bigbluebutton.main.model.users
LOGGER.debug("*** handleValidateAuthTokenTimedOut. valid=[{0}] **** \n", [tokenValid]);
dispatcher.dispatchEvent(new InvalidAuthTokenEvent());
}
if (reconnecting) {
onReconnect();
reconnecting = false;
}

}

private function handleValidateAuthTokenReply(msg: Object):void {
Expand All @@ -185,18 +182,6 @@ package org.bigbluebutton.main.model.users
LOGGER.debug("*** handleValidateAuthTokenReply. valid=[{0}] **** \n", [tokenValid]);
dispatcher.dispatchEvent(new InvalidAuthTokenEvent());
}
if (reconnecting) {
onReconnect();
reconnecting = false;
}
}

private function onReconnect():void {
if (authenticated) {
onReconnectSuccess();
} else {
onReconnectFailed();
}
}

private function onReconnectSuccess():void {
Expand Down Expand Up @@ -308,7 +293,10 @@ package org.bigbluebutton.main.model.users
case "NetConnection.Connect.Success":
LOGGER.debug("Connection to viewers application succeeded.");
JSLog.debug("Successfully connected to BBB App.", logData);

if (reconnecting) {
reconnecting = false;
onReconnectSuccess();
}
validateToken();

break;
Expand Down

0 comments on commit 52d2ed1

Please sign in to comment.