diff --git a/example/lib/exts.dart b/example/lib/exts.dart index 8712a866..04316565 100644 --- a/example/lib/exts.dart +++ b/example/lib/exts.dart @@ -214,4 +214,6 @@ enum SimulateScenarioResult { switchCandidate, clear, e2eeKeyRatchet, + participantName, + participantMetadata, } diff --git a/example/lib/pages/room.dart b/example/lib/pages/room.dart index 95e7cec7..39471d2d 100644 --- a/example/lib/pages/room.dart +++ b/example/lib/pages/room.dart @@ -82,6 +82,14 @@ class _RoomPageState extends State { ..on((event) { print( 'Participant name updated: ${event.participant.identity}, name => ${event.name}'); + _sortParticipants(); + }) + ..on((event) { + print( + 'Participant metadata updated: ${event.participant.identity}, metadata => ${event.metadata}'); + }) + ..on((event) { + print('Room metadata changed: ${event.metadata}'); }) ..on((event) { String decoded = 'Failed to decode'; diff --git a/example/lib/widgets/controls.dart b/example/lib/widgets/controls.dart index 8998888e..356269d7 100644 --- a/example/lib/widgets/controls.dart +++ b/example/lib/widgets/controls.dart @@ -239,6 +239,16 @@ class _ControlsWidgetState extends State { await widget.room.e2eeManager?.ratchetKey(); } + if (SimulateScenarioResult.participantMetadata == result) { + widget.room.localParticipant?.setMetadata( + 'new metadata ${widget.room.localParticipant?.identity}'); + } + + if (SimulateScenarioResult.participantName == result) { + widget.room.localParticipant + ?.setName('new name for ${widget.room.localParticipant?.identity}'); + } + await widget.room.sendSimulateScenario( signalReconnect: result == SimulateScenarioResult.signalReconnect ? true : null, diff --git a/lib/src/events.dart b/lib/src/events.dart index 01237d66..963fcadf 100644 --- a/lib/src/events.dart +++ b/lib/src/events.dart @@ -330,8 +330,10 @@ class TrackStreamStateUpdatedEvent with RoomEvent, ParticipantEvent { /// Emitted by [Room] and [Participant]. class ParticipantMetadataUpdatedEvent with RoomEvent, ParticipantEvent { final Participant participant; + final String metadata; const ParticipantMetadataUpdatedEvent({ required this.participant, + required this.metadata, }); @override diff --git a/lib/src/participant/participant.dart b/lib/src/participant/participant.dart index d08435ff..4fe96323 100644 --- a/lib/src/participant/participant.dart +++ b/lib/src/participant/participant.dart @@ -164,6 +164,7 @@ abstract class Participant if (changed) { [events, room.events].emit(ParticipantMetadataUpdatedEvent( participant: this, + metadata: md, )); } }