Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-04-07 13:21:13 +0300
committerJoas Schilling <coding@schilljs.com>2020-04-07 13:28:23 +0300
commitd43ca31ba1c0ca77c315af874d03c6707568742b (patch)
tree8042a84db2517a08dafcee8800f22286730351fe /lib
parent4271eeb5e01c23a9d952784503791d4009667e56 (diff)
Ping all session ids with 1 query from the external signaling
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Controller/SignalingController.php10
-rw-r--r--lib/Room.php14
2 files changed, 20 insertions, 4 deletions
diff --git a/lib/Controller/SignalingController.php b/lib/Controller/SignalingController.php
index 437560bca..d1af3c9aa 100644
--- a/lib/Controller/SignalingController.php
+++ b/lib/Controller/SignalingController.php
@@ -473,15 +473,17 @@ class SignalingController extends OCSController {
]);
}
+ $pingSessionIds = [];
$now = $this->timeFactory->getTime();
foreach ($request['entries'] as $entry) {
- if (array_key_exists('userid', $entry)) {
- $room->ping($entry['userid'], $entry['sessionid'], $now);
- } else {
- $room->ping('', $entry['sessionid'], $now);
+ if ($entry['sessionid'] !== '0') {
+ $pingSessionIds[] = $entry['sessionid'];
}
}
+ // Ping all active sessions with one query
+ $room->pingSessionIds($pingSessionIds, $now);
+
$response = [
'type' => 'room',
'room' => [
diff --git a/lib/Room.php b/lib/Room.php
index d77380093..6c1e87ed2 100644
--- a/lib/Room.php
+++ b/lib/Room.php
@@ -1240,4 +1240,18 @@ class Room {
$query->execute();
}
+
+ /**
+ * @param string[] $sessionIds
+ * @param int $timestamp
+ */
+ public function pingSessionIds(array $sessionIds, int $timestamp): void {
+ $query = $this->db->getQueryBuilder();
+ $query->update('talk_participants')
+ ->set('last_ping', $query->createNamedParameter($timestamp, IQueryBuilder::PARAM_INT))
+ ->where($query->expr()->eq('room_id', $query->createNamedParameter($this->getId(), IQueryBuilder::PARAM_INT)))
+ ->andWhere($query->expr()->in('session_id', $query->createNamedParameter($sessionIds), IQueryBuilder::PARAM_STR_ARRAY));
+
+ $query->execute();
+ }
}