Update user last activity time when he sends a message.

This commit is contained in:
Ghazi Triki 2018-07-30 11:43:12 +01:00
parent ffb6d6e593
commit dffeeb8daf
8 changed files with 29 additions and 22 deletions

View File

@ -1,13 +1,13 @@
package org.bigbluebutton.core.apps.users
import org.bigbluebutton.common2.msgs.UserActivitySignResponseMsg
import org.bigbluebutton.common2.msgs.UserActivitySignCmdMsg
import org.bigbluebutton.core.models.Users2x
import org.bigbluebutton.core.running.MeetingActor
trait UserActivitySignResponseMsgHdlr {
trait UserActivitySignCmdMsgHdlr {
this: MeetingActor =>
def handleUserActivitySignResponseMsg(msg: UserActivitySignResponseMsg): Unit = {
def handleUserActivitySignCmdMsg(msg: UserActivitySignCmdMsg): Unit = {
for {
user <- Users2x.findWithIntId(liveMeeting.users2x, msg.body.userId)
} yield {

View File

@ -94,8 +94,8 @@ class ReceivedJsonMsgHandlerActor(
routeGenericMsg[RemoveUserFromPresenterGroupCmdMsg](envelope, jsonNode)
case GetPresenterGroupReqMsg.NAME =>
routeGenericMsg[GetPresenterGroupReqMsg](envelope, jsonNode)
case UserActivitySignResponseMsg.NAME =>
routeGenericMsg[UserActivitySignResponseMsg](envelope, jsonNode)
case UserActivitySignCmdMsg.NAME =>
routeGenericMsg[UserActivitySignCmdMsg](envelope, jsonNode)
// Poll
case StartCustomPollReqMsg.NAME =>

View File

@ -78,7 +78,7 @@ class MeetingActor(
with SyncGetMeetingInfoRespMsgHdlr
with ClientToServerLatencyTracerMsgHdlr
with ValidateConnAuthTokenSysMsgHdlr
with UserActivitySignResponseMsgHdlr {
with UserActivitySignCmdMsgHdlr {
override val supervisorStrategy = OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1 minute) {
case e: Exception => {
@ -395,26 +395,30 @@ class MeetingActor(
case m: SendPrivateMessagePubMsg =>
chatApp2x.handle(m, liveMeeting, msgBus)
updateUserLastActivity(m.body.message.fromUserId)
case m: ClearPublicChatHistoryPubMsg => state = chatApp2x.handle(m, state, liveMeeting, msgBus)
case m: ClearPublicChatHistoryPubMsg => state = chatApp2x.handle(m, state, liveMeeting, msgBus)
// Screenshare
case m: ScreenshareStartedVoiceConfEvtMsg => screenshareApp2x.handle(m, liveMeeting, msgBus)
case m: ScreenshareStoppedVoiceConfEvtMsg => screenshareApp2x.handle(m, liveMeeting, msgBus)
case m: ScreenshareStartedVoiceConfEvtMsg => screenshareApp2x.handle(m, liveMeeting, msgBus)
case m: ScreenshareStoppedVoiceConfEvtMsg => screenshareApp2x.handle(m, liveMeeting, msgBus)
case m: ScreenshareRtmpBroadcastStartedVoiceConfEvtMsg => screenshareApp2x.handle(m, liveMeeting, msgBus)
case m: ScreenshareRtmpBroadcastStoppedVoiceConfEvtMsg => screenshareApp2x.handle(m, liveMeeting, msgBus)
case m: GetScreenshareStatusReqMsg => screenshareApp2x.handle(m, liveMeeting, msgBus)
case m: GetScreenshareStatusReqMsg => screenshareApp2x.handle(m, liveMeeting, msgBus)
// GroupChat
case m: CreateGroupChatReqMsg => state = groupChatApp.handle(m, state, liveMeeting, msgBus)
case m: CreateGroupChatReqMsg =>
state = groupChatApp.handle(m, state, liveMeeting, msgBus)
updateUserLastActivity(m.header.userId)
case m: GetGroupChatMsgsReqMsg => state = groupChatApp.handle(m, state, liveMeeting, msgBus)
case m: GetGroupChatsReqMsg => state = groupChatApp.handle(m, state, liveMeeting, msgBus)
case m: SendGroupChatMessageMsg => state = groupChatApp.handle(m, state, liveMeeting, msgBus)
case m: GetGroupChatsReqMsg => state = groupChatApp.handle(m, state, liveMeeting, msgBus)
case m: SendGroupChatMessageMsg =>
state = groupChatApp.handle(m, state, liveMeeting, msgBus)
updateUserLastActivity(m.body.msg.sender.id)
case m: ValidateConnAuthTokenSysMsg => handleValidateConnAuthTokenSysMsg(m)
case m: UserActivitySignResponseMsg => handleUserActivitySignResponseMsg(m)
case m: UserActivitySignCmdMsg => handleUserActivitySignCmdMsg(m)
case _ => log.warning("***** Cannot handle " + msg.envelope.name)
case _ => log.warning("***** Cannot handle " + msg.envelope.name)
}
}
@ -613,6 +617,7 @@ class MeetingActor(
}
def warnPotentiallyInactiveUsers(): Unit = {
log.info("Checking for potentially inactive users and sending them a message to show a sign of life.")
val users = Users2x.findAll(liveMeeting.users2x)
users foreach { u =>
val active = (lastUserInactivityInspectSentOn - expiryTracker.userInactivityThresholdInMs) < u.lastActivityTime
@ -623,6 +628,7 @@ class MeetingActor(
}
def disconnectInactiveUsers(): Unit = {
log.info("Disconnecting inactive users that didn't show any sign of life since we warned them.")
val users = Users2x.findAll(liveMeeting.users2x)
users foreach { u =>
val respondedOntIme = (lastUserInactivityInspectSentOn - expiryTracker.userInactivityThresholdInMs) < u.lastActivityTime && (lastUserInactivityInspectSentOn + expiryTracker.userActivitySignResponseDelayInMs) > u.lastActivityTime

View File

@ -82,6 +82,7 @@ class AnalyticsActor extends Actor with ActorLogging {
case m: UserBroadcastCamStoppedEvtMsg => logMessage(msg)
case m: UserBroadcastCamStartedEvtMsg => logMessage(msg)
case m: EjectUserFromMeetingSysMsg => logMessage(msg)
case m: UserActivitySignCmdMsg => logMessage(msg)
case m: UserInactivityInspectMsg => logMessage(msg)
case m: ChangeUserRoleCmdMsg => logMessage(msg)

View File

@ -18,8 +18,8 @@ object Sender {
}
def sendUserInactivityInspectMsg(meetingId: String, userId: String, responseDelay: Long, outGW: OutMsgRouter): Unit = {
val ejectFromMeetingSystemEvent = MsgBuilder.buildUserInactivityInspectMsg(meetingId, userId, responseDelay)
outGW.send(ejectFromMeetingSystemEvent)
val userInactivityInspectMsg = MsgBuilder.buildUserInactivityInspectMsg(meetingId, userId, responseDelay)
outGW.send(userInactivityInspectMsg)
}
}

View File

@ -34,7 +34,7 @@ object AllowedMessageNames {
GetGuestPolicyReqMsg.NAME,
SetGuestPolicyCmdMsg.NAME,
GuestsWaitingApprovedMsg.NAME,
UserActivitySignResponseMsg.NAME,
UserActivitySignCmdMsg.NAME,
// Webcams
GetWebcamsOnlyForModeratorReqMsg.NAME,

View File

@ -378,6 +378,6 @@ object UserInactivityInspectMsg { val NAME = "UserInactivityInspectMsg" }
case class UserInactivityInspectMsg(header: BbbClientMsgHeader, body: UserInactivityInspectMsgBody) extends StandardMsg
case class UserInactivityInspectMsgBody(meetingId: String, responseDelay: Long)
object UserActivitySignResponseMsg { val NAME = "UserActivitySignResponseMsg" }
case class UserActivitySignResponseMsg(header: BbbClientMsgHeader, body: UserActivitySignResponseMsgBody) extends StandardMsg
case class UserActivitySignResponseMsgBody(userId: String)
object UserActivitySignCmdMsg { val NAME = "UserActivitySignCmdMsg" }
case class UserActivitySignCmdMsg(header: BbbClientMsgHeader, body: UserActivitySignCmdMsgBody) extends StandardMsg
case class UserActivitySignCmdMsgBody(userId: String)

View File

@ -329,7 +329,7 @@ package org.bigbluebutton.modules.users.services
public function userActivitySignResponse():void {
var message:Object = {
header: {name: "UserActivitySignResponseMsg", meetingId: UsersUtil.getInternalMeetingID(),
header: {name: "UserActivitySignCmdMsg", meetingId: UsersUtil.getInternalMeetingID(),
userId: UsersUtil.getMyUserID()},
body: {userId: UsersUtil.getMyUserID()}
};