From 1983bc521b82146cbe1370ad9e57675b7d6b88ff Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 10 Jul 2018 16:29:35 +0200 Subject: [PATCH] Simplify the code and allow 100 secs as timeout (3 pings and a little buffer) Signed-off-by: Joas Schilling --- lib/Controller/RoomController.php | 13 ++++--------- lib/Room.php | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index ad04832635e3..73022d0fc265 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -217,19 +217,14 @@ protected function formatRoom(Room $room, Participant $participant = null) { 'call' => $data['inCall'], ]; } - } - - $inactiveUsers = array_filter($participants['users'], function($data) { - return $data['lastPing'] <= time() - 30 && - $data['sessionId'] !== 0 && $data['sessionId'] !== '' && $data['sessionId'] !== '0'; - }); - foreach ($inactiveUsers as $inactiveUserId => $data) { - $room->leaveRoom($inactiveUserId); + if ($data['sessionId'] !== '0' && $data['lastPing'] <= time() - 100) { + $room->leaveRoom($userId); + } } $activeGuests = array_filter($participants['guests'], function($data) { - return $data['lastPing'] > time() - 30; + return $data['lastPing'] > time() - 100; }); $numActiveGuests = count($activeGuests); diff --git a/lib/Room.php b/lib/Room.php index c1dc2d4d2406..e7428526c987 100644 --- a/lib/Room.php +++ b/lib/Room.php @@ -659,7 +659,7 @@ public function cleanGuestParticipants() { $query->delete('talk_participants') ->where($query->expr()->eq('room_id', $query->createNamedParameter($this->getId(), IQueryBuilder::PARAM_INT))) ->andWhere($query->expr()->emptyString('user_id')) - ->andWhere($query->expr()->lte('last_ping', $query->createNamedParameter(time() - 30, IQueryBuilder::PARAM_INT))); + ->andWhere($query->expr()->lte('last_ping', $query->createNamedParameter(time() - 100, IQueryBuilder::PARAM_INT))); $query->execute(); $this->dispatcher->dispatch(self::class . '::postCleanGuests', new GenericEvent($this));