Skip to content

Commit

Permalink
fix: set attributes of remote participants earlier
Browse files Browse the repository at this point in the history
Otherwise the attributes are not set during the "ParticipantConnected"
event
  • Loading branch information
holzgeist committed Dec 5, 2024
1 parent 23aceba commit 462f7f3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
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

0 comments on commit 462f7f3

Please sign in to comment.