Skip to content

Commit

Permalink
Merge pull request #1534 from nextcloud/fix-slower-active-peers-not-i…
Browse files Browse the repository at this point in the history
…ncluded-in-user-list-returned-by-signaling

Fix slower active users not included in user list returned by signaling
  • Loading branch information
nickvergessen authored Feb 13, 2019
2 parents 8331d43 + 022466e commit 13433b1
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/Controller/SignalingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
use Symfony\Component\EventDispatcher\GenericEvent;

class SignalingController extends OCSController {

/** @var int */
private const PULL_MESSAGES_TIMEOUT = 30;

/** @var Config */
private $config;
/** @var TalkSession */
Expand Down Expand Up @@ -143,7 +147,7 @@ public function pullMessages(string $token): DataResponse {
}

$data = [];
$seconds = 30;
$seconds = self::PULL_MESSAGES_TIMEOUT;

try {
$sessionId = $this->session->getSessionForRoom($token);
Expand Down Expand Up @@ -211,10 +215,11 @@ public function pullMessages(string $token): DataResponse {
*/
protected function getUsersInRoom(Room $room, int $pingTimestamp): array {
$usersInRoom = [];
// Get participants active in the last 30 seconds, or since the last
// signaling ping of the current user if it was done more than 30
// seconds ago.
$timestamp = min(time() - 30, $pingTimestamp);
// Get participants active in the last 40 seconds (an extra time is used
// to include other participants pinging almost at the same time as the
// current user), or since the last signaling ping of the current user
// if it was done more than 40 seconds ago.
$timestamp = min(time() - (self::PULL_MESSAGES_TIMEOUT + 10), $pingTimestamp);
// "- 1" is needed because only the participants whose last ping is
// greater than the given timestamp are returned.
$participants = $room->getParticipants($timestamp - 1);
Expand Down

0 comments on commit 13433b1

Please sign in to comment.