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

Add method to populate an offline room with simulated participants #531

Merged
merged 10 commits into from
Dec 9, 2022
Prev Previous commit
Next Next commit
register events on local participant
  • Loading branch information
lukasIO committed Dec 7, 2022
commit c525779ff9715e33a9f0b3c4cd1a0841a2a78570
14 changes: 13 additions & 1 deletion src/room/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,18 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
count: number,
options: { audio?: boolean; video?: boolean; aspectRatios: Array<number> },
) {
this.localParticipant
.on(ParticipantEvent.ParticipantMetadataChanged, this.onLocalParticipantMetadataChanged)
.on(ParticipantEvent.TrackMuted, this.onLocalTrackMuted)
.on(ParticipantEvent.TrackUnmuted, this.onLocalTrackUnmuted)
.on(ParticipantEvent.LocalTrackPublished, this.onLocalTrackPublished)
.on(ParticipantEvent.LocalTrackUnpublished, this.onLocalTrackUnpublished)
.on(ParticipantEvent.ConnectionQualityChanged, this.onLocalConnectionQualityChanged)
.on(ParticipantEvent.MediaDevicesError, this.onMediaDevicesError)
.on(
ParticipantEvent.ParticipantPermissionsChanged,
this.onLocalParticipantPermissionsChanged,
);
this.emit(RoomEvent.SignalConnected);
this.emit(RoomEvent.Connected);
this.setAndEmitConnectionState(ConnectionState.Connected);
Expand All @@ -1279,7 +1291,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
// @ts-ignore
this.localParticipant.addTrackPublication(pub);
this.localParticipant.emit(ParticipantEvent.LocalTrackPublished, pub);
this.emit(RoomEvent.LocalTrackPublished, pub, this.localParticipant);

for (let i = 0; i < count - 1; i += 1) {
let info: ParticipantInfo = ParticipantInfo.fromPartial({
sid: Math.floor(Math.random() * 10_000).toString(),
Expand Down