feat: support metadata update. (#259)

This commit is contained in:
CloudWebRTC
2023-03-27 09:19:52 +08:00
committed by GitHub
parent 68d611a448
commit bc4df105fa
5 changed files with 57 additions and 1 deletions
+23
View File
@@ -276,6 +276,29 @@ class LocalParticipant extends Participant<LocalTrackPublication> {
await room.engine.sendDataPacket(packet);
}
/// Sets and updates the metadata of the local participant.
/// Note: this requires `CanUpdateOwnMetadata` permission encoded in the token.
/// @param metadata
void setMetadata(String metadata) {
room.engine.signalClient
.sendUpdateLocalMetadata(lk_rtc.UpdateParticipantMetadata(
name: name,
metadata: metadata,
));
}
/// Sets and updates the name of the local participant.
/// Note: this requires `CanUpdateOwnMetadata` permission encoded in the token.
/// @param name
void setName(String name) {
super.updateName(name);
room.engine.signalClient
.sendUpdateLocalMetadata(lk_rtc.UpdateParticipantMetadata(
name: name,
metadata: metadata,
));
}
/// A convenience property to get all video tracks.
@override
List<LocalTrackPublication<LocalVideoTrack>> get videoTracks =>
+11 -1
View File
@@ -159,8 +159,8 @@ abstract class Participant<T extends TrackPublication>
@internal
void updateFromInfo(lk_models.ParticipantInfo info) {
identity = info.identity;
_name = info.name;
sid = info.sid;
updateName(info.name);
if (info.metadata.isNotEmpty) {
_setMetadata(info.metadata);
}
@@ -177,6 +177,16 @@ abstract class Participant<T extends TrackPublication>
return oldValue;
}
@internal
void updateName(String name) {
if (_name == name) return;
_name = name;
[events, room.events].emit(ParticipantNameUpdatedEvent(
participant: this,
name: name,
));
}
/// for internal use
/// {@nodoc}
@internal