Skip to content

Commit

Permalink
fixed: presenter problem + set ping interval 1 minute
Browse files Browse the repository at this point in the history
  • Loading branch information
jibon57 committed Sep 2, 2024
1 parent ac37f38 commit 473f374
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
10 changes: 7 additions & 3 deletions pkg/models/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,21 @@ func (m *SchedulerModel) StartScheduler() {
checkRoomDuration := time.NewTicker(5 * time.Second)
defer checkRoomDuration.Stop()

roomChecker := time.NewTicker(5 * time.Minute)
defer roomChecker.Stop()
fiveMinutesChecker := time.NewTicker(5 * time.Minute)
defer fiveMinutesChecker.Stop()

oneMinuteChecker := time.NewTicker(1 * time.Minute)
defer oneMinuteChecker.Stop()

for {
select {
case <-m.closeTicker:
return
case <-checkRoomDuration.C:
m.checkRoomWithDuration()
case <-oneMinuteChecker.C:
m.checkOnlineUsersStatus()
case <-roomChecker.C:
case <-fiveMinutesChecker.C:
m.activeRoomChecker()
}
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/models/user_presenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ func (m *UserModel) CreateNewPresenter(r *plugnmeet.GenerateTokenReq) error {
if err != nil {
return err
}

if ids == nil || len(ids) == 0 {
// no user found
r.UserInfo.UserMetadata.IsPresenter = true
return nil
}

for _, id := range ids {
if entry, err := m.natsService.GetUserKeyValue(r.RoomId, string(id.Value()), natsservice.UserIsPresenterKey); err == nil && entry != nil {
for id := range ids {
if entry, err := m.natsService.GetUserKeyValue(r.RoomId, id, natsservice.UserIsPresenterKey); err == nil && entry != nil {
if string(entry.Value()) == "true" {
// session already has presenter
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/nats/user_modify.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const (

RoomUsersBlockList = Prefix + "usersBlockList-%s"

UserOnlineMaxPingDiff = time.Second * 30 // after 30 seconds we'll treat user as offline
UserOnlineMaxPingDiff = time.Minute * 2 // after 2 minutes we'll treat user as offline

UserIdKey = "id"
UserSidKey = "sid"
Expand Down

0 comments on commit 473f374

Please sign in to comment.