这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion Runtime/Scripts/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public enum RoomEvent
[EnumMember(Value = "audioPlaybackChanged")]
AudioPlaybackStatusChanged,
[EnumMember(Value = "mediaDevicesError")]
MediaDevicesError
MediaDevicesError,
[EnumMember(Value = "participantAttributesChanged")]
ParticipantAttributesChanged,
}

[JsonConverter(typeof(StringEnumConverter))]
Expand Down
17 changes: 17 additions & 0 deletions Runtime/Scripts/Room/Participant/LocalParticipant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 +193,22 @@ public void SetTrackSubscriptionPermissions(bool allParticipantsAllowed,

JSNative.CallMethod(NativeHandle, "setTrackSubscriptionPermissions");
}

public JSPromise SetName(string name)
{
JSNative.PushString(name);
return Acquire<JSPromise>(JSNative.CallMethod(NativeHandle, "setName"));
}

public JSPromise SetMetadata(string metadata)
{
JSNative.PushString(metadata);
return Acquire<JSPromise>(JSNative.CallMethod(NativeHandle, "setMetadata"));
}

public JSPromise SetAttributes(JSMap<string, string> attributes) {
JSNative.PushObject(attributes.NativeHandle);
return Acquire<JSPromise>(JSNative.CallMethod(NativeHandle, "setAttributes"));
}
}
}
9 changes: 9 additions & 0 deletions Runtime/Scripts/Room/Participant/Participant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ public string Metadata
}
}

public JSMap<string,string> attributes
{
get
{
JSNative.PushString("attributes");
return Acquire<JSMap<string,string>>(JSNative.GetProperty(NativeHandle));
}
}

public DateTime? LastSpokeAt
{
get
Expand Down
10 changes: 10 additions & 0 deletions Runtime/Scripts/Room/Room.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class Room : JSEventEmitter<RoomEvent>, 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<string, string> changedAttributes);

public event ReconnectingDelegate Reconnecting;
public event ReconnectedDelegate Reconnected;
Expand All @@ -71,6 +72,7 @@ public class Room : JSEventEmitter<RoomEvent>, 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)
Expand Down Expand Up @@ -285,6 +287,14 @@ private static void EventReceived(IntPtr iptr)
room.AudioPlaybackChanged?.Invoke(status);
break;
}
case RoomEvent.ParticipantAttributesChanged:
{
var changedAttributes = Acquire<JSMap<string, string>>(JSNative.ShiftStack());
var participant = Acquire<Participant>(JSNative.ShiftStack());
Log.Debug($"Room: Received AttributesChanged({participant.Sid}, {changedAttributes})");
room.AttributesChanged?.Invoke(participant, changedAttributes);
break;
}
}
}
catch (Exception e)
Expand Down