From 473f3747b67232af712d918bde81d1f6e760fc02 Mon Sep 17 00:00:00 2001 From: "Jibon L. Costa" Date: Mon, 2 Sep 2024 23:00:33 +0200 Subject: [PATCH] fixed: presenter problem + set ping interval 1 minute --- pkg/models/scheduler.go | 10 +++++++--- pkg/models/user_presenter.go | 5 +++-- pkg/services/nats/user_modify.go | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pkg/models/scheduler.go b/pkg/models/scheduler.go index a94c5f67..c9bdd705 100644 --- a/pkg/models/scheduler.go +++ b/pkg/models/scheduler.go @@ -51,8 +51,11 @@ 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 { @@ -60,8 +63,9 @@ func (m *SchedulerModel) StartScheduler() { return case <-checkRoomDuration.C: m.checkRoomWithDuration() + case <-oneMinuteChecker.C: m.checkOnlineUsersStatus() - case <-roomChecker.C: + case <-fiveMinutesChecker.C: m.activeRoomChecker() } } diff --git a/pkg/models/user_presenter.go b/pkg/models/user_presenter.go index 8cab4445..72916749 100644 --- a/pkg/models/user_presenter.go +++ b/pkg/models/user_presenter.go @@ -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 diff --git a/pkg/services/nats/user_modify.go b/pkg/services/nats/user_modify.go index 42be9440..837ceb13 100644 --- a/pkg/services/nats/user_modify.go +++ b/pkg/services/nats/user_modify.go @@ -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"