diff --git a/Runtime/Scripts/Events.cs b/Runtime/Scripts/Events.cs index 36eff2e..049766d 100644 --- a/Runtime/Scripts/Events.cs +++ b/Runtime/Scripts/Events.cs @@ -56,7 +56,9 @@ public enum RoomEvent [EnumMember(Value = "audioPlaybackChanged")] AudioPlaybackStatusChanged, [EnumMember(Value = "mediaDevicesError")] - MediaDevicesError + MediaDevicesError, + [EnumMember(Value = "participantAttributesChanged")] + ParticipantAttributesChanged, } [JsonConverter(typeof(StringEnumConverter))] diff --git a/Runtime/Scripts/Room/Participant/LocalParticipant.cs b/Runtime/Scripts/Room/Participant/LocalParticipant.cs index 49f693d..3ea0b72 100644 --- a/Runtime/Scripts/Room/Participant/LocalParticipant.cs +++ b/Runtime/Scripts/Room/Participant/LocalParticipant.cs @@ -193,5 +193,22 @@ public void SetTrackSubscriptionPermissions(bool allParticipantsAllowed, JSNative.CallMethod(NativeHandle, "setTrackSubscriptionPermissions"); } + + public JSPromise SetName(string name) + { + JSNative.PushString(name); + return Acquire(JSNative.CallMethod(NativeHandle, "setName")); + } + + public JSPromise SetMetadata(string metadata) + { + JSNative.PushString(metadata); + return Acquire(JSNative.CallMethod(NativeHandle, "setMetadata")); + } + + public JSPromise SetAttributes(JSMap attributes) { + JSNative.PushObject(attributes.NativeHandle); + return Acquire(JSNative.CallMethod(NativeHandle, "setAttributes")); + } } } \ No newline at end of file diff --git a/Runtime/Scripts/Room/Participant/Participant.cs b/Runtime/Scripts/Room/Participant/Participant.cs index 5ef7bda..1af0c48 100644 --- a/Runtime/Scripts/Room/Participant/Participant.cs +++ b/Runtime/Scripts/Room/Participant/Participant.cs @@ -153,6 +153,15 @@ public string Metadata } } + public JSMap attributes + { + get + { + JSNative.PushString("attributes"); + return Acquire>(JSNative.GetProperty(NativeHandle)); + } + } + public DateTime? LastSpokeAt { get diff --git a/Runtime/Scripts/Room/Room.cs b/Runtime/Scripts/Room/Room.cs index ac12103..a184703 100644 --- a/Runtime/Scripts/Room/Room.cs +++ b/Runtime/Scripts/Room/Room.cs @@ -46,6 +46,7 @@ public class Room : JSEventEmitter, IDisposable public delegate void TrackStreamStateChangedDelegate(RemoteTrackPublication publication, TrackStreamState streamState, RemoteParticipant participant); public delegate void TrackSubscriptionPermissionChangedDelegate(RemoteTrackPublication publication, SubscriptionStatus status, RemoteParticipant participant); public delegate void AudioPlaybackChangedDelegate(bool playing); + public delegate void AttributesChangedDelegate(Participant participant, JSMap changedAttributes); public event ReconnectingDelegate Reconnecting; public event ReconnectedDelegate Reconnected; @@ -71,6 +72,7 @@ public class Room : JSEventEmitter, IDisposable public event TrackStreamStateChangedDelegate TrackStreamStateChanged; public event TrackSubscriptionPermissionChangedDelegate TrackSubscriptionPermissionChanged; public event AudioPlaybackChangedDelegate AudioPlaybackChanged; + public event AttributesChangedDelegate AttributesChanged; [MonoPInvokeCallback(typeof(JSNative.JSDelegate))] private static void EventReceived(IntPtr iptr) @@ -285,6 +287,14 @@ private static void EventReceived(IntPtr iptr) room.AudioPlaybackChanged?.Invoke(status); break; } + case RoomEvent.ParticipantAttributesChanged: + { + var changedAttributes = Acquire>(JSNative.ShiftStack()); + var participant = Acquire(JSNative.ShiftStack()); + Log.Debug($"Room: Received AttributesChanged({participant.Sid}, {changedAttributes})"); + room.AttributesChanged?.Invoke(participant, changedAttributes); + break; + } } } catch (Exception e)