Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Notify external signaling server when description changes
Signed-off-by: Daniel Calviño Sánchez <[email protected]>
  • Loading branch information
danxuliu authored and nickvergessen committed Dec 8, 2020
commit f52aa0cf47f134d50824f0afbecd7374dadb5ba2
9 changes: 8 additions & 1 deletion lib/Room.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,10 @@ public function setParticipant(?string $userId, Participant $participant): void
* Return the room properties to send to the signaling server.
*
* @param string $userId
* @param bool $roomModified
* @return array
*/
public function getPropertiesForSignaling(string $userId): array {
public function getPropertiesForSignaling(string $userId, bool $roomModified = true): array {
$properties = [
'name' => $this->getDisplayName($userId),
'type' => $this->getType(),
Expand All @@ -349,6 +350,12 @@ public function getPropertiesForSignaling(string $userId): array {
'sip-enabled' => $this->getSIPEnabled(),
];

if ($roomModified) {
$properties = array_merge($properties, [
'description' => $this->getDescription(),
]);
Comment on lines +354 to +356
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not changing anything on the signaling?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is getPropertiesForSignaling but the data is not used in signaling, so we don't need to expose it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new description will be relayed by the signaling server to the clients in the roomlist->update message. Currently we are not using the updated properties from the message, though, but I think it is better to send it for consistency with the rest of the update messages.

}

$event = new SignalingRoomPropertiesEvent($this, $userId, $properties);
$this->dispatcher->dispatch(self::EVENT_BEFORE_SIGNALING_PROPERTIES, $event);
return $event->getProperties();
Expand Down
6 changes: 3 additions & 3 deletions lib/Signaling/BackendNotifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function roomInvited(Room $room, array $users): void {
// TODO(fancycode): We should try to get rid of 'alluserids' and
// find a better way to notify existing users to update the room.
'alluserids' => $this->participantService->getParticipantUserIds($room),
'properties' => $room->getPropertiesForSignaling(''),
'properties' => $room->getPropertiesForSignaling('', false),
],
]);
}
Expand All @@ -180,7 +180,7 @@ public function roomsDisinvited(Room $room, array $userIds): void {
// TODO(fancycode): We should try to get rid of 'alluserids' and
// find a better way to notify existing users to update the room.
'alluserids' => $this->participantService->getParticipantUserIds($room),
'properties' => $room->getPropertiesForSignaling(''),
'properties' => $room->getPropertiesForSignaling('', false),
],
]);
}
Expand All @@ -201,7 +201,7 @@ public function roomSessionsRemoved(Room $room, array $sessionIds): void {
// TODO(fancycode): We should try to get rid of 'alluserids' and
// find a better way to notify existing users to update the room.
'alluserids' => $this->participantService->getParticipantUserIds($room),
'properties' => $room->getPropertiesForSignaling(''),
'properties' => $room->getPropertiesForSignaling('', false),
],
]);
}
Expand Down
1 change: 1 addition & 0 deletions lib/Signaling/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ protected static function registerExternalSignaling(IEventDispatcher $dispatcher
$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);
Expand Down
29 changes: 29 additions & 0 deletions tests/php/Signaling/BackendNotifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,30 @@ public function testRoomNameChanged() {
],
'properties' => [
'name' => $room->getDisplayName(''),
'description' => '',
'type' => $room->getType(),
'lobby-state' => Webinary::LOBBY_NONE,
'lobby-timer' => null,
'read-only' => Room::READ_WRITE,
'active-since' => null,
'sip-enabled' => 0,
],
],
]);
}

public function testRoomDescriptionChanged() {
$room = $this->manager->createRoom(Room::PUBLIC_CALL);
$room->setDescription('The description');

$this->assertMessageWasSent($room, [
'type' => 'update',
'update' => [
'userids' => [
],
'properties' => [
'name' => $room->getDisplayName(''),
'description' => 'The description',
'type' => $room->getType(),
'lobby-state' => Webinary::LOBBY_NONE,
'lobby-timer' => null,
Expand All @@ -327,6 +351,7 @@ public function testRoomPasswordChanged() {
],
'properties' => [
'name' => $room->getDisplayName(''),
'description' => '',
'type' => $room->getType(),
'lobby-state' => Webinary::LOBBY_NONE,
'lobby-timer' => null,
Expand All @@ -349,6 +374,7 @@ public function testRoomTypeChanged() {
],
'properties' => [
'name' => $room->getDisplayName(''),
'description' => '',
'type' => $room->getType(),
'lobby-state' => Webinary::LOBBY_NONE,
'lobby-timer' => null,
Expand All @@ -371,6 +397,7 @@ public function testRoomReadOnlyChanged() {
],
'properties' => [
'name' => $room->getDisplayName(''),
'description' => '',
'type' => $room->getType(),
'lobby-state' => Webinary::LOBBY_NONE,
'lobby-timer' => null,
Expand All @@ -393,6 +420,7 @@ public function testRoomLobbyStateChanged() {
],
'properties' => [
'name' => $room->getDisplayName(''),
'description' => '',
'type' => $room->getType(),
'lobby-state' => Webinary::LOBBY_NON_MODERATORS,
'lobby-timer' => null,
Expand Down Expand Up @@ -551,6 +579,7 @@ public function testRoomPropertiesEvent(): void {
],
'properties' => [
'name' => $room->getDisplayName(''),
'description' => '',
'type' => $room->getType(),
'lobby-state' => Webinary::LOBBY_NONE,
'lobby-timer' => null,
Expand Down