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>2022-01-26 11:20:44 +0300
committerJoas Schilling <coding@schilljs.com>2022-01-26 12:18:23 +0300
commit3ba29c0478eaa54d90d12175e0620ec041827025 (patch)
tree1ecfcbdcf1e89eee8b331b5f9b521abc39f1e009 /lib
parent0abdf03ba06a1d6e5878d44c772343a5c8d1adf0 (diff)
Only send 1 HPB request for the "end call for everyone" case
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Events/EndCallForEveryoneEvent.php54
-rw-r--r--lib/Service/ParticipantService.php8
-rw-r--r--lib/Signaling/Listener.php30
3 files changed, 90 insertions, 2 deletions
diff --git a/lib/Events/EndCallForEveryoneEvent.php b/lib/Events/EndCallForEveryoneEvent.php
new file mode 100644
index 000000000..a080e5f07
--- /dev/null
+++ b/lib/Events/EndCallForEveryoneEvent.php
@@ -0,0 +1,54 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Talk\Events;
+
+use OCA\Talk\Participant;
+use OCA\Talk\Room;
+
+class EndCallForEveryoneEvent extends ModifyRoomEvent {
+
+ /** @var string[] */
+ protected $sessionIds;
+
+ public function __construct(Room $room,
+ ?Participant $actor = null) {
+ parent::__construct($room, 'in_call', Participant::FLAG_DISCONNECTED, null, $actor);
+ }
+
+ /**
+ * @param string[] $sessionIds
+ * @return void
+ */
+ public function setSessionIds(array $sessionIds): void {
+ $this->sessionIds = $sessionIds;
+ }
+
+ /**
+ * Only available in the after-event
+ * @return string[]
+ */
+ public function getSessionIds(): array {
+ return $this->sessionIds;
+ }
+}
diff --git a/lib/Service/ParticipantService.php b/lib/Service/ParticipantService.php
index d11bf996e..2bd4010fd 100644
--- a/lib/Service/ParticipantService.php
+++ b/lib/Service/ParticipantService.php
@@ -30,11 +30,11 @@ use OCA\Talk\Config;
use OCA\Talk\Events\AddParticipantsEvent;
use OCA\Talk\Events\AttendeesAddedEvent;
use OCA\Talk\Events\AttendeesRemovedEvent;
+use OCA\Talk\Events\EndCallForEveryoneEvent;
use OCA\Talk\Events\JoinRoomGuestEvent;
use OCA\Talk\Events\JoinRoomUserEvent;
use OCA\Talk\Events\ModifyEveryoneEvent;
use OCA\Talk\Events\ModifyParticipantEvent;
-use OCA\Talk\Events\ModifyRoomEvent;
use OCA\Talk\Events\ParticipantEvent;
use OCA\Talk\Events\RemoveParticipantEvent;
use OCA\Talk\Events\RemoveUserEvent;
@@ -908,16 +908,20 @@ class ParticipantService {
}
public function endCallForEveryone(Room $room, Participant $moderator): void {
- $event = new ModifyRoomEvent($room, 'in_call', Participant::FLAG_DISCONNECTED, null, $moderator);
+ $event = new EndCallForEveryoneEvent($room, $moderator);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_END_CALL_FOR_EVERYONE, $event);
$participants = $this->getParticipantsInCall($room);
+ $changedSessionIds = [];
// kick out all participants out of the call
foreach ($participants as $participant) {
+ $changedSessionIds[] = $participant->getSession()->getSessionId();
$this->changeInCall($room, $participant, Participant::FLAG_DISCONNECTED, true);
}
+ $event->setSessionIds($changedSessionIds);
+
$this->dispatcher->dispatch(Room::EVENT_AFTER_END_CALL_FOR_EVERYONE, $event);
}
diff --git a/lib/Signaling/Listener.php b/lib/Signaling/Listener.php
index 829218efc..dce9087a0 100644
--- a/lib/Signaling/Listener.php
+++ b/lib/Signaling/Listener.php
@@ -28,6 +28,8 @@ use OCA\Talk\Config;
use OCA\Talk\Events\AddParticipantsEvent;
use OCA\Talk\Events\ChatEvent;
use OCA\Talk\Events\ChatParticipantEvent;
+use OCA\Talk\Events\EndCallForEveryoneEvent;
+use OCA\Talk\Events\ModifyEveryoneEvent;
use OCA\Talk\Events\ModifyParticipantEvent;
use OCA\Talk\Events\ParticipantEvent;
use OCA\Talk\Events\RemoveParticipantEvent;
@@ -235,6 +237,13 @@ class Listener {
return;
}
+ if ($event instanceof ModifyEveryoneEvent) {
+ // If everyone is disconnected, we will not do O(n) requests.
+ // Instead, the listener of Room::EVENT_AFTER_END_CALL_FOR_EVERYONE
+ // will send all sessions to the HPB with 1 request.
+ return;
+ }
+
/** @var BackendNotifier $notifier */
$notifier = \OC::$server->get(BackendNotifier::class);
@@ -259,6 +268,27 @@ class Listener {
$dispatcher->addListener(Room::EVENT_AFTER_SESSION_UPDATE_CALL_FLAGS, $listener);
$dispatcher->addListener(Room::EVENT_AFTER_SESSION_LEAVE_CALL, $listener);
+ $dispatcher->addListener(Room::EVENT_AFTER_END_CALL_FOR_EVERYONE, static function (EndCallForEveryoneEvent $event): void {
+ if (self::isUsingInternalSignaling()) {
+ return;
+ }
+
+ $sessionIds = $event->getSessionIds();
+
+ if (empty($sessionIds)) {
+ return;
+ }
+
+ /** @var BackendNotifier $notifier */
+ $notifier = \OC::$server->get(BackendNotifier::class);
+
+ $notifier->roomInCallChanged(
+ $event->getRoom(),
+ $event->getNewValue(),
+ $sessionIds
+ );
+ });
+
$dispatcher->addListener(Room::EVENT_AFTER_GUESTS_CLEAN, static function (RoomEvent $event) {
if (self::isUsingInternalSignaling()) {
return;