Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set attributes of remote participants on participant creation #1344

Merged
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
5 changes: 5 additions & 0 deletions .changeset/tiny-adults-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'livekit-client': patch
---

Set participant attributes as soon as possible, making them available in all related events
16 changes: 12 additions & 4 deletions src/room/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1733,10 +1733,18 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
loggerName: this.options.loggerName,
});
} else {
participant = new RemoteParticipant(this.engine.client, '', identity, undefined, undefined, {
loggerContextCb: () => this.logContext,
loggerName: this.options.loggerName,
});
participant = new RemoteParticipant(
this.engine.client,
'',
identity,
undefined,
undefined,
undefined,
{
loggerContextCb: () => this.logContext,
loggerName: this.options.loggerName,
},
);
}
if (this.options.webAudioMix) {
participant.setAudioContext(this.audioContext);
Expand Down
4 changes: 4 additions & 0 deletions src/room/participant/LocalParticipant.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe('LocalParticipant', () => {
'Remote Participant',
'',
undefined,
undefined,
ParticipantKind.STANDARD,
);

Expand Down Expand Up @@ -92,6 +93,7 @@ describe('LocalParticipant', () => {
'Remote Participant',
'',
undefined,
undefined,
ParticipantKind.STANDARD,
);

Expand Down Expand Up @@ -134,6 +136,7 @@ describe('LocalParticipant', () => {
'Remote Participant',
'',
undefined,
undefined,
ParticipantKind.STANDARD,
);

Expand Down Expand Up @@ -196,6 +199,7 @@ describe('LocalParticipant', () => {
'Remote Participant',
'',
undefined,
undefined,
ParticipantKind.STANDARD,
);
});
Expand Down
2 changes: 1 addition & 1 deletion src/room/participant/LocalParticipant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export default class LocalParticipant extends Participant {

/** @internal */
constructor(sid: string, identity: string, engine: RTCEngine, options: InternalRoomOptions) {
super(sid, identity, undefined, undefined, {
super(sid, identity, undefined, undefined, undefined, {
loggerName: options.loggerName,
loggerContextCb: () => this.engine.logContext,
});
Expand Down
3 changes: 2 additions & 1 deletion src/room/participant/Participant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export default class Participant extends (EventEmitter as new () => TypedEmitter
identity: string,
name?: string,
metadata?: string,
attributes?: Record<string, string>,
loggerOptions?: LoggerOptions,
kind: ParticipantKind = ParticipantKind.STANDARD,
) {
Expand All @@ -143,7 +144,7 @@ export default class Participant extends (EventEmitter as new () => TypedEmitter
this.videoTrackPublications = new Map();
this.trackPublications = new Map();
this._kind = kind;
this._attributes = {};
this._attributes = attributes ?? {};
}

getTrackPublications(): TrackPublication[] {
Expand Down
4 changes: 3 additions & 1 deletion src/room/participant/RemoteParticipant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default class RemoteParticipant extends Participant {
pi.identity,
pi.name,
pi.metadata,
pi.attributes,
loggerOptions,
pi.kind,
);
Expand All @@ -64,10 +65,11 @@ export default class RemoteParticipant extends Participant {
identity?: string,
name?: string,
metadata?: string,
attributes?: Record<string, string>,
loggerOptions?: LoggerOptions,
kind: ParticipantKind = ParticipantKind.STANDARD,
) {
super(sid, identity || '', name, metadata, loggerOptions, kind);
super(sid, identity || '', name, metadata, attributes, loggerOptions, kind);
this.signalClient = signalClient;
this.trackPublications = new Map();
this.audioTrackPublications = new Map();
Expand Down
Loading