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 <213943+nickvergessen@users.noreply.github.com>2022-04-26 10:07:10 +0300
committerGitHub <noreply@github.com>2022-04-26 10:07:10 +0300
commit6e442c4d3ca9246de748f2ad42c53decbd2135dc (patch)
tree31dbef4405fb790c730541b1213348593fabadd6 /lib
parenta449038406b75e28d92070a38399b9d9de6e034a (diff)
parenta404591bb8ec9517eb45a1681267805708687ea5 (diff)
Merge pull request #7213 from nextcloud/feature/move-signaling-listeners-anonymous-functions-to-static
Move signaling listeners anonymous functions to static
Diffstat (limited to 'lib')
-rw-r--r--lib/Signaling/Listener.php511
1 files changed, 257 insertions, 254 deletions
diff --git a/lib/Signaling/Listener.php b/lib/Signaling/Listener.php
index 26af22371..899932108 100644
--- a/lib/Signaling/Listener.php
+++ b/lib/Signaling/Listener.php
@@ -54,312 +54,315 @@ class Listener {
}
protected static function registerInternalSignaling(IEventDispatcher $dispatcher): void {
- $listener = static function (RoomEvent $event): void {
- if (!self::isUsingInternalSignaling()) {
- return;
- }
+ $dispatcher->addListener(Room::EVENT_AFTER_ROOM_CONNECT, [self::class, 'refreshParticipantListUsingRoomEvent']);
+ $dispatcher->addListener(Room::EVENT_AFTER_GUEST_CONNECT, [self::class, 'refreshParticipantListUsingRoomEvent']);
+ $dispatcher->addListener(Room::EVENT_AFTER_SESSION_JOIN_CALL, [self::class, 'refreshParticipantListUsingRoomEvent']);
+ $dispatcher->addListener(Room::EVENT_AFTER_SESSION_UPDATE_CALL_FLAGS, [self::class, 'refreshParticipantListUsingRoomEvent']);
+ $dispatcher->addListener(Room::EVENT_AFTER_SESSION_LEAVE_CALL, [self::class, 'refreshParticipantListUsingRoomEvent']);
+ $dispatcher->addListener(Room::EVENT_AFTER_PERMISSIONS_SET, [self::class, 'refreshParticipantListUsingRoomEvent']);
+ $dispatcher->addListener(GuestManager::EVENT_AFTER_NAME_UPDATE, [self::class, 'refreshParticipantListUsingRoomEvent']);
+ $dispatcher->addListener(Room::EVENT_BEFORE_ROOM_DELETE, [self::class, 'refreshParticipantListUsingRoomEvent']);
+
+ $dispatcher->addListener(Room::EVENT_BEFORE_USER_REMOVE, [self::class, 'refreshParticipantListUsingParticipantEvent']);
+ $dispatcher->addListener(Room::EVENT_BEFORE_PARTICIPANT_REMOVE, [self::class, 'refreshParticipantListUsingParticipantEvent']);
+ $dispatcher->addListener(Room::EVENT_BEFORE_ROOM_DISCONNECT, [self::class, 'refreshParticipantListUsingParticipantEvent']);
+ $dispatcher->addListener(Room::EVENT_AFTER_PARTICIPANT_PERMISSIONS_SET, [self::class, 'refreshParticipantListUsingParticipantEvent']);
+ }
- /** @var Messages $messages */
- $messages = \OC::$server->get(Messages::class);
- $messages->addMessageForAllParticipants($event->getRoom(), 'refresh-participant-list');
- };
- $dispatcher->addListener(Room::EVENT_AFTER_ROOM_CONNECT, $listener);
- $dispatcher->addListener(Room::EVENT_AFTER_GUEST_CONNECT, $listener);
- $dispatcher->addListener(Room::EVENT_AFTER_SESSION_JOIN_CALL, $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_PERMISSIONS_SET, $listener);
- $dispatcher->addListener(GuestManager::EVENT_AFTER_NAME_UPDATE, $listener);
-
- $listener = static function (ParticipantEvent $event): void {
- if (!self::isUsingInternalSignaling()) {
- return;
- }
+ protected static function registerExternalSignaling(IEventDispatcher $dispatcher): void {
+ $dispatcher->addListener(Room::EVENT_AFTER_USERS_ADD, [self::class, 'notifyAfterUsersAdd']);
+ $dispatcher->addListener(Room::EVENT_AFTER_NAME_SET, [self::class, 'notifyAfterRoomSettingsChanged']);
+ $dispatcher->addListener(Room::EVENT_AFTER_DESCRIPTION_SET, [self::class, 'notifyAfterRoomSettingsChanged']);
+ $dispatcher->addListener(Room::EVENT_AFTER_PASSWORD_SET, [self::class, 'notifyAfterRoomSettingsChanged']);
+ $dispatcher->addListener(Room::EVENT_AFTER_TYPE_SET, [self::class, 'notifyAfterRoomSettingsChanged']);
+ $dispatcher->addListener(Room::EVENT_AFTER_READONLY_SET, [self::class, 'notifyAfterRoomSettingsChanged']);
+ $dispatcher->addListener(Room::EVENT_AFTER_LISTABLE_SET, [self::class, 'notifyAfterRoomSettingsChanged']);
+ $dispatcher->addListener(Room::EVENT_AFTER_LOBBY_STATE_SET, [self::class, 'notifyAfterRoomSettingsChanged']);
+ $dispatcher->addListener(Room::EVENT_AFTER_SIP_ENABLED_SET, [self::class, 'notifyAfterRoomSettingsChanged']);
+ // TODO remove handler with "roomModified" in favour of handler with
+ // "participantsModified" once the clients no longer expect a
+ // "roomModified" message for participant type changes.
+ $dispatcher->addListener(Room::EVENT_AFTER_PARTICIPANT_TYPE_SET, [self::class, 'notifyAfterRoomSettingsChanged']);
+ $dispatcher->addListener(Room::EVENT_AFTER_PARTICIPANT_TYPE_SET, [self::class, 'notifyAfterParticipantTypeAndPermissionsSet']);
+ $dispatcher->addListener(Room::EVENT_AFTER_PARTICIPANT_PERMISSIONS_SET, [self::class, 'notifyAfterParticipantTypeAndPermissionsSet']);
+ $dispatcher->addListener(Room::EVENT_AFTER_PERMISSIONS_SET, [self::class, 'notifyAfterPermissionSet']);
+ $dispatcher->addListener(Room::EVENT_BEFORE_ROOM_DELETE, [self::class, 'notifyBeforeRoomDeleted']);
+ $dispatcher->addListener(Room::EVENT_AFTER_USER_REMOVE, [self::class, 'notifyAfterUserRemoved']);
+ $dispatcher->addListener(Room::EVENT_AFTER_PARTICIPANT_REMOVE, [self::class, 'notifyAfterParticipantRemoved']);
+ $dispatcher->addListener(Room::EVENT_AFTER_ROOM_DISCONNECT, [self::class, 'notifyAfterRoomDisconected']);
+ $dispatcher->addListener(Room::EVENT_AFTER_SESSION_JOIN_CALL, [self::class, 'notifyAfterJoinUpdateAndLeave']);
+ $dispatcher->addListener(Room::EVENT_AFTER_SESSION_UPDATE_CALL_FLAGS, [self::class, 'notifyAfterJoinUpdateAndLeave']);
+ $dispatcher->addListener(Room::EVENT_AFTER_SESSION_LEAVE_CALL, [self::class, 'notifyAfterJoinUpdateAndLeave']);
+ $dispatcher->addListener(Room::EVENT_AFTER_END_CALL_FOR_EVERYONE, [self::class, 'sendEndCallForEveryone']);
+ $dispatcher->addListener(Room::EVENT_AFTER_GUESTS_CLEAN, [self::class, 'notifyParticipantsAfterGuestClean']);
+ $dispatcher->addListener(GuestManager::EVENT_AFTER_NAME_UPDATE, [self::class, 'notifyParticipantsAfterNameUpdated']);
+ $dispatcher->addListener(ChatManager::EVENT_AFTER_MESSAGE_SEND, [self::class, 'notifyUsersViaExternalSignalingToRefreshTheChat']);
+ $dispatcher->addListener(ChatManager::EVENT_AFTER_SYSTEM_MESSAGE_SEND, [self::class, 'notifyUsersViaExternalSignalingToRefreshTheChat']);
+ $dispatcher->addListener(ChatManager::EVENT_AFTER_MULTIPLE_SYSTEM_MESSAGE_SEND, [self::class, 'notifyUsersViaExternalSignalingToRefreshTheChat']);
+ }
- $room = $event->getRoom();
-
- /** @var Messages $messages */
- $messages = \OC::$server->get(Messages::class);
- $messages->addMessageForAllParticipants($room, 'refresh-participant-list');
- };
- $dispatcher->addListener(Room::EVENT_BEFORE_USER_REMOVE, $listener);
- $dispatcher->addListener(Room::EVENT_BEFORE_PARTICIPANT_REMOVE, $listener);
- $dispatcher->addListener(Room::EVENT_BEFORE_ROOM_DISCONNECT, $listener);
- $dispatcher->addListener(Room::EVENT_AFTER_PARTICIPANT_PERMISSIONS_SET, $listener);
-
- $listener = static function (RoomEvent $event): void {
- $room = $event->getRoom();
- if (!self::isUsingInternalSignaling()) {
- return;
- }
+ public static function refreshParticipantListUsingRoomEvent(RoomEvent $event): void {
+ if (!self::isUsingInternalSignaling()) {
+ return;
+ }
- /** @var Messages $messages */
- $messages = \OC::$server->get(Messages::class);
- $messages->addMessageForAllParticipants($room, 'refresh-participant-list');
- };
- $dispatcher->addListener(Room::EVENT_BEFORE_ROOM_DELETE, $listener);
+ /** @var Messages $messages */
+ $messages = \OC::$server->get(Messages::class);
+ $messages->addMessageForAllParticipants($event->getRoom(), 'refresh-participant-list');
}
- protected static function registerExternalSignaling(IEventDispatcher $dispatcher): void {
- $dispatcher->addListener(Room::EVENT_AFTER_USERS_ADD, static function (AddParticipantsEvent $event) {
- if (self::isUsingInternalSignaling()) {
- return;
- }
+ public static function refreshParticipantListUsingParticipantEvent(ParticipantEvent $event): void {
+ if (!self::isUsingInternalSignaling()) {
+ return;
+ }
- /** @var BackendNotifier $notifier */
- $notifier = \OC::$server->get(BackendNotifier::class);
+ /** @var Messages $messages */
+ $messages = \OC::$server->get(Messages::class);
+ $messages->addMessageForAllParticipants($event->getRoom(), 'refresh-participant-list');
+ }
- $notifier->roomInvited($event->getRoom(), $event->getParticipants());
- });
- $listener = static function (RoomEvent $event): void {
- if (self::isUsingInternalSignaling()) {
- return;
- }
+ public static function notifyAfterUsersAdd(AddParticipantsEvent $event): void {
+ if (self::isUsingInternalSignaling()) {
+ return;
+ }
- /** @var BackendNotifier $notifier */
- $notifier = \OC::$server->get(BackendNotifier::class);
-
- $notifier->roomModified($event->getRoom());
- };
- $dispatcher->addListener(Room::EVENT_AFTER_NAME_SET, $listener);
- $dispatcher->addListener(Room::EVENT_AFTER_DESCRIPTION_SET, $listener);
- $dispatcher->addListener(Room::EVENT_AFTER_PASSWORD_SET, $listener);
- $dispatcher->addListener(Room::EVENT_AFTER_TYPE_SET, $listener);
- $dispatcher->addListener(Room::EVENT_AFTER_READONLY_SET, $listener);
- $dispatcher->addListener(Room::EVENT_AFTER_LISTABLE_SET, $listener);
- $dispatcher->addListener(Room::EVENT_AFTER_LOBBY_STATE_SET, $listener);
- $dispatcher->addListener(Room::EVENT_AFTER_SIP_ENABLED_SET, $listener);
- // TODO remove handler with "roomModified" in favour of handler with
- // "participantsModified" once the clients no longer expect a
- // "roomModified" message for participant type changes.
- $dispatcher->addListener(Room::EVENT_AFTER_PARTICIPANT_TYPE_SET, $listener);
+ /** @var BackendNotifier $notifier */
+ $notifier = \OC::$server->get(BackendNotifier::class);
- $listener = static function (ModifyParticipantEvent $event): void {
- if (self::isUsingInternalSignaling()) {
- return;
- }
+ $notifier->roomInvited($event->getRoom(), $event->getParticipants());
+ }
- /** @var BackendNotifier $notifier */
- $notifier = \OC::$server->get(BackendNotifier::class);
+ public static function notifyAfterRoomSettingsChanged(RoomEvent $event): void {
+ if (self::isUsingInternalSignaling()) {
+ return;
+ }
- $sessionIds = [];
- // If the participant is not active in the room the "participants"
- // request will be sent anyway, although with an empty "changed"
- // property.
+ /** @var BackendNotifier $notifier */
+ $notifier = \OC::$server->get(BackendNotifier::class);
- /** @var SessionService $sessionService */
- $sessionService = \OC::$server->get(SessionService::class);
- $sessions = $sessionService->getAllSessionsForAttendee($event->getParticipant()->getAttendee());
- foreach ($sessions as $session) {
- $sessionIds[] = $session->getSessionId();
- }
+ $notifier->roomModified($event->getRoom());
+ }
- $notifier->participantsModified($event->getRoom(), $sessionIds);
- };
- $dispatcher->addListener(Room::EVENT_AFTER_PARTICIPANT_TYPE_SET, $listener);
- $dispatcher->addListener(Room::EVENT_AFTER_PARTICIPANT_PERMISSIONS_SET, $listener);
+ public static function notifyAfterParticipantTypeAndPermissionsSet(ModifyParticipantEvent $event): void {
+ if (self::isUsingInternalSignaling()) {
+ return;
+ }
- $dispatcher->addListener(Room::EVENT_AFTER_PERMISSIONS_SET, static function (RoomEvent $event) {
- if (self::isUsingInternalSignaling()) {
- return;
- }
+ /** @var BackendNotifier $notifier */
+ $notifier = \OC::$server->get(BackendNotifier::class);
- /** @var BackendNotifier $notifier */
- $notifier = \OC::$server->get(BackendNotifier::class);
-
- $sessionIds = [];
-
- // Setting the room permissions resets the permissions of all
- // participants, even those with custom attendee permissions.
-
- // FIXME This approach does not scale, as the update message for all
- // the sessions in a conversation can exceed the allowed size of the
- // request in conversations with a large number of participants.
- // However, note that a single message with the general permissions
- // to be set on all participants can not be sent either, as the
- // general permissions could be overriden by custom attendee
- // permissions in specific participants.
-
- /** @var ParticipantService $participantService */
- $participantService = \OC::$server->get(ParticipantService::class);
- $participants = $participantService->getSessionsAndParticipantsForRoom($event->getRoom());
- foreach ($participants as $participant) {
- $session = $participant->getSession();
- if ($session) {
- $sessionIds[] = $session->getSessionId();
- }
- }
+ $sessionIds = [];
+ // If the participant is not active in the room the "participants"
+ // request will be sent anyway, although with an empty "changed"
+ // property.
- $notifier->participantsModified($event->getRoom(), $sessionIds);
- });
+ /** @var SessionService $sessionService */
+ $sessionService = \OC::$server->get(SessionService::class);
+ $sessions = $sessionService->getAllSessionsForAttendee($event->getParticipant()->getAttendee());
+ foreach ($sessions as $session) {
+ $sessionIds[] = $session->getSessionId();
+ }
- $dispatcher->addListener(Room::EVENT_BEFORE_ROOM_DELETE, static function (RoomEvent $event) {
- if (self::isUsingInternalSignaling()) {
- return;
- }
+ $notifier->participantsModified($event->getRoom(), $sessionIds);
+ }
- /** @var BackendNotifier $notifier */
- $notifier = \OC::$server->get(BackendNotifier::class);
- /** @var ParticipantService $participantService */
- $participantService = \OC::$server->get(ParticipantService::class);
-
- $room = $event->getRoom();
- $notifier->roomDeleted($room, $participantService->getParticipantUserIds($room));
- });
- $dispatcher->addListener(Room::EVENT_AFTER_USER_REMOVE, static function (RemoveUserEvent $event) {
- if (self::isUsingInternalSignaling()) {
- return;
- }
+ public static function notifyAfterPermissionSet(RoomEvent $event): void {
+ if (self::isUsingInternalSignaling()) {
+ return;
+ }
- /** @var BackendNotifier $notifier */
- $notifier = \OC::$server->get(BackendNotifier::class);
+ /** @var BackendNotifier $notifier */
+ $notifier = \OC::$server->get(BackendNotifier::class);
- $notifier->roomsDisinvited($event->getRoom(), [$event->getUser()->getUID()]);
- });
- $dispatcher->addListener(Room::EVENT_AFTER_PARTICIPANT_REMOVE, static function (RemoveParticipantEvent $event) {
- if (self::isUsingInternalSignaling()) {
- return;
+ $sessionIds = [];
+
+ // Setting the room permissions resets the permissions of all
+ // participants, even those with custom attendee permissions.
+
+ // FIXME This approach does not scale, as the update message for all
+ // the sessions in a conversation can exceed the allowed size of the
+ // request in conversations with a large number of participants.
+ // However, note that a single message with the general permissions
+ // to be set on all participants can not be sent either, as the
+ // general permissions could be overriden by custom attendee
+ // permissions in specific participants.
+
+ /** @var ParticipantService $participantService */
+ $participantService = \OC::$server->get(ParticipantService::class);
+ $participants = $participantService->getSessionsAndParticipantsForRoom($event->getRoom());
+ foreach ($participants as $participant) {
+ $session = $participant->getSession();
+ if ($session) {
+ $sessionIds[] = $session->getSessionId();
}
+ }
- /** @var BackendNotifier $notifier */
- $notifier = \OC::$server->get(BackendNotifier::class);
+ $notifier->participantsModified($event->getRoom(), $sessionIds);
+ }
- $sessionIds = [];
+ public static function notifyBeforeRoomDeleted(RoomEvent $event): void {
+ if (self::isUsingInternalSignaling()) {
+ return;
+ }
- /** @var SessionService $sessionService */
- $sessionService = \OC::$server->get(SessionService::class);
- $sessions = $sessionService->getAllSessionsForAttendee($event->getParticipant()->getAttendee());
- foreach ($sessions as $session) {
- $sessionIds[] = $session->getSessionId();
- }
+ /** @var BackendNotifier $notifier */
+ $notifier = \OC::$server->get(BackendNotifier::class);
+ /** @var ParticipantService $participantService */
+ $participantService = \OC::$server->get(ParticipantService::class);
- if ($event->getParticipant()->getSession()) {
- $sessionIds[] = $event->getParticipant()->getSession()->getSessionId();
- $notifier->roomSessionsRemoved($event->getRoom(), $sessionIds);
- }
+ $room = $event->getRoom();
+ $notifier->roomDeleted($room, $participantService->getParticipantUserIds($room));
+ }
- if (!empty($sessionIds)) {
- $notifier->roomSessionsRemoved($event->getRoom(), $sessionIds);
- }
- });
- $dispatcher->addListener(Room::EVENT_AFTER_ROOM_DISCONNECT, static function (ParticipantEvent $event) {
- if (self::isUsingInternalSignaling()) {
- return;
- }
+ public static function notifyAfterUserRemoved(RemoveUserEvent $event): void {
+ if (self::isUsingInternalSignaling()) {
+ return;
+ }
- /** @var BackendNotifier $notifier */
- $notifier = \OC::$server->get(BackendNotifier::class);
-
- $sessionIds = [];
- if ($event->getParticipant()->getSession()) {
- // Only for guests and self-joined users disconnecting is "leaving" and therefor should trigger a disinvite
- $attendeeParticipantType = $event->getParticipant()->getAttendee()->getParticipantType();
- if ($attendeeParticipantType === Participant::GUEST
- || $attendeeParticipantType === Participant::GUEST_MODERATOR) {
- $sessionIds[] = $event->getParticipant()->getSession()->getSessionId();
- $notifier->roomSessionsRemoved($event->getRoom(), $sessionIds);
- }
- if ($attendeeParticipantType === Participant::USER_SELF_JOINED) {
- $notifier->roomsDisinvited($event->getRoom(), [$event->getParticipant()->getAttendee()->getActorId()]);
- }
- }
- });
+ /** @var BackendNotifier $notifier */
+ $notifier = \OC::$server->get(BackendNotifier::class);
- $listener = static function (ModifyParticipantEvent $event): void {
- if (self::isUsingInternalSignaling()) {
- return;
- }
+ $notifier->roomsDisinvited($event->getRoom(), [$event->getUser()->getUID()]);
+ }
- 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;
- }
+ public static function notifyAfterParticipantRemoved(RemoveParticipantEvent $event): void {
+ if (self::isUsingInternalSignaling()) {
+ return;
+ }
+
+ /** @var BackendNotifier $notifier */
+ $notifier = \OC::$server->get(BackendNotifier::class);
- /** @var BackendNotifier $notifier */
- $notifier = \OC::$server->get(BackendNotifier::class);
+ $sessionIds = [];
- $sessionIds = [];
+ /** @var SessionService $sessionService */
+ $sessionService = \OC::$server->get(SessionService::class);
+ $sessions = $sessionService->getAllSessionsForAttendee($event->getParticipant()->getAttendee());
+ foreach ($sessions as $session) {
+ $sessionIds[] = $session->getSessionId();
+ }
- /** @var SessionService $sessionService */
- $sessionService = \OC::$server->get(SessionService::class);
- $sessions = $sessionService->getAllSessionsForAttendee($event->getParticipant()->getAttendee());
- foreach ($sessions as $session) {
- $sessionIds[] = $session->getSessionId();
- }
+ if ($event->getParticipant()->getSession()) {
+ $sessionIds[] = $event->getParticipant()->getSession()->getSessionId();
+ $notifier->roomSessionsRemoved($event->getRoom(), $sessionIds);
+ }
- if (!empty($sessionIds)) {
- $notifier->roomInCallChanged(
- $event->getRoom(),
- $event->getNewValue(),
- $sessionIds
- );
+ if (!empty($sessionIds)) {
+ $notifier->roomSessionsRemoved($event->getRoom(), $sessionIds);
+ }
+ }
+
+ public static function notifyAfterRoomDisconected(ParticipantEvent $event): void {
+ if (self::isUsingInternalSignaling()) {
+ return;
+ }
+
+ /** @var BackendNotifier $notifier */
+ $notifier = \OC::$server->get(BackendNotifier::class);
+
+ $sessionIds = [];
+ if ($event->getParticipant()->getSession()) {
+ // Only for guests and self-joined users disconnecting is "leaving" and therefor should trigger a disinvite
+ $attendeeParticipantType = $event->getParticipant()->getAttendee()->getParticipantType();
+ if ($attendeeParticipantType === Participant::GUEST
+ || $attendeeParticipantType === Participant::GUEST_MODERATOR) {
+ $sessionIds[] = $event->getParticipant()->getSession()->getSessionId();
+ $notifier->roomSessionsRemoved($event->getRoom(), $sessionIds);
}
- };
- $dispatcher->addListener(Room::EVENT_AFTER_SESSION_JOIN_CALL, $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;
+ if ($attendeeParticipantType === Participant::USER_SELF_JOINED) {
+ $notifier->roomsDisinvited($event->getRoom(), [$event->getParticipant()->getAttendee()->getActorId()]);
}
+ }
+ }
- $sessionIds = $event->getSessionIds();
+ public static function notifyAfterJoinUpdateAndLeave(ModifyParticipantEvent $event): void {
+ if (self::isUsingInternalSignaling()) {
+ return;
+ }
- if (empty($sessionIds)) {
- 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);
+
+ $sessionIds = [];
- /** @var BackendNotifier $notifier */
- $notifier = \OC::$server->get(BackendNotifier::class);
+ /** @var SessionService $sessionService */
+ $sessionService = \OC::$server->get(SessionService::class);
+ $sessions = $sessionService->getAllSessionsForAttendee($event->getParticipant()->getAttendee());
+ foreach ($sessions as $session) {
+ $sessionIds[] = $session->getSessionId();
+ }
+ if (!empty($sessionIds)) {
$notifier->roomInCallChanged(
$event->getRoom(),
$event->getNewValue(),
$sessionIds
);
- });
+ }
+ }
- $dispatcher->addListener(Room::EVENT_AFTER_GUESTS_CLEAN, static function (RoomEvent $event) {
- if (self::isUsingInternalSignaling()) {
- return;
- }
+ public static function sendEndCallForEveryone(EndCallForEveryoneEvent $event): void {
+ if (self::isUsingInternalSignaling()) {
+ return;
+ }
- /** @var BackendNotifier $notifier */
- $notifier = \OC::$server->get(BackendNotifier::class);
+ $sessionIds = $event->getSessionIds();
- // TODO: The list of removed session ids should be passed through the event
- // so the signaling server can optimize forwarding the message.
- $sessionIds = [];
- $notifier->participantsModified($event->getRoom(), $sessionIds);
- });
- $dispatcher->addListener(GuestManager::EVENT_AFTER_NAME_UPDATE, static function (ModifyParticipantEvent $event) {
- if (self::isUsingInternalSignaling()) {
- return;
- }
+ if (empty($sessionIds)) {
+ return;
+ }
- /** @var BackendNotifier $notifier */
- $notifier = \OC::$server->get(BackendNotifier::class);
+ /** @var BackendNotifier $notifier */
+ $notifier = \OC::$server->get(BackendNotifier::class);
- $sessionIds = [];
+ $notifier->roomInCallChanged(
+ $event->getRoom(),
+ $event->getNewValue(),
+ $sessionIds
+ );
+ }
- /** @var SessionService $sessionService */
- $sessionService = \OC::$server->get(SessionService::class);
- $sessions = $sessionService->getAllSessionsForAttendee($event->getParticipant()->getAttendee());
- foreach ($sessions as $session) {
- $sessionIds[] = $session->getSessionId();
- }
+ public static function notifyParticipantsAfterGuestClean(RoomEvent $event): void {
+ if (self::isUsingInternalSignaling()) {
+ return;
+ }
- if (!empty($sessionIds)) {
- $notifier->participantsModified($event->getRoom(), $sessionIds);
- }
- });
+ /** @var BackendNotifier $notifier */
+ $notifier = \OC::$server->get(BackendNotifier::class);
- $dispatcher->addListener(ChatManager::EVENT_AFTER_MESSAGE_SEND, [self::class, 'notifyUsersViaExternalSignalingToRefreshTheChat']);
- $dispatcher->addListener(ChatManager::EVENT_AFTER_SYSTEM_MESSAGE_SEND, [self::class, 'notifyUsersViaExternalSignalingToRefreshTheChat']);
- $dispatcher->addListener(ChatManager::EVENT_AFTER_MULTIPLE_SYSTEM_MESSAGE_SEND, [self::class, 'notifyUsersViaExternalSignalingToRefreshTheChat']);
+ // TODO: The list of removed session ids should be passed through the event
+ // so the signaling server can optimize forwarding the message.
+ $sessionIds = [];
+ $notifier->participantsModified($event->getRoom(), $sessionIds);
+ }
+
+ public static function notifyParticipantsAfterNameUpdated(ModifyParticipantEvent $event): void {
+ if (self::isUsingInternalSignaling()) {
+ return;
+ }
+
+ /** @var BackendNotifier $notifier */
+ $notifier = \OC::$server->get(BackendNotifier::class);
+
+ $sessionIds = [];
+
+ /** @var SessionService $sessionService */
+ $sessionService = \OC::$server->get(SessionService::class);
+ $sessions = $sessionService->getAllSessionsForAttendee($event->getParticipant()->getAttendee());
+ foreach ($sessions as $session) {
+ $sessionIds[] = $session->getSessionId();
+ }
+
+ if (!empty($sessionIds)) {
+ $notifier->participantsModified($event->getRoom(), $sessionIds);
+ }
}
public static function notifyUsersViaExternalSignalingToRefreshTheChat(ChatEvent $event): void {