@@ -155,7 +155,14 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
155155 }
156156
157157 get creationTime ( ) : Date {
158- return new Date ( Number ( this . info ?. creationTime ?? 0 ) ) ;
158+ // TODO: workaround for Rust SDK bug, remove after updating to:
159+ // https://github.com/livekit/rust-sdks/pull/822
160+ // check if creationTime looks like seconds (less than year 3000 in ms), convert to ms if needed
161+ let creationTimeMs = Number ( this . info ?. creationTime ?? 0 ) ;
162+ if ( creationTimeMs > 0 && creationTimeMs < 1e12 ) {
163+ creationTimeMs *= 1000 ;
164+ }
165+ return new Date ( creationTimeMs ) ;
159166 }
160167
161168 get isRecording ( ) : boolean {
@@ -362,7 +369,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
362369 participant . info . disconnectReason = ev . value . disconnectReason ;
363370 this . emit ( RoomEvent . ParticipantDisconnected , participant ) ;
364371 } else {
365- console . log ( `RoomEvent.ParticipantDisconnected: Could not find participant` ) ;
372+ log . warn ( `RoomEvent.ParticipantDisconnected: Could not find participant` ) ;
366373 }
367374 } else if ( ev . case == 'localTrackPublished' ) {
368375 const publication = this . localParticipant . trackPublications . get ( ev . value . trackSid ! ) ;
@@ -377,15 +384,15 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
377384 publication . resolveFirstSubscription ( ) ;
378385 this . emit ( RoomEvent . LocalTrackSubscribed , publication ! . track ! ) ;
379386 } else {
380- console . warn ( `RoomEvent.LocalTrackSubscribed: Publication not found: ${ ev . value . trackSid } ` ) ;
387+ log . warn ( `RoomEvent.LocalTrackSubscribed: Publication not found: ${ ev . value . trackSid } ` ) ;
381388 }
382389 } else if ( ev . case == 'trackPublished' ) {
383390 const participant = this . remoteParticipants . get ( ev . value . participantIdentity ! ) ;
384391 const publication = new RemoteTrackPublication ( ev . value . publication ! ) ;
385392 if ( participant ) {
386393 participant . trackPublications . set ( publication . sid ! , publication ) ;
387394 } else {
388- console . warn (
395+ log . warn (
389396 `RoomEvent.TrackPublished: Could not find participant: ${ ev . value . participantIdentity } ` ,
390397 ) ;
391398 }
@@ -397,7 +404,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
397404 if ( publication ) {
398405 this . emit ( RoomEvent . TrackUnpublished , publication , participant ) ;
399406 } else {
400- console . warn ( `RoomEvent.TrackUnpublished: Could not find publication` ) ;
407+ log . warn ( `RoomEvent.TrackUnpublished: Could not find publication` ) ;
401408 }
402409 } else if ( ev . case == 'trackSubscribed' ) {
403410 const ownedTrack = ev . value . track ! ;
@@ -416,7 +423,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
416423
417424 this . emit ( RoomEvent . TrackSubscribed , publication . track ! , publication , participant ) ;
418425 } catch ( e : unknown ) {
419- console . warn ( `RoomEvent.TrackSubscribed: ${ ( e as Error ) . message } ` ) ;
426+ log . warn ( `RoomEvent.TrackSubscribed: ${ ( e as Error ) . message } ` ) ;
420427 }
421428 } else if ( ev . case == 'trackUnsubscribed' ) {
422429 try {
@@ -429,7 +436,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
429436 publication . subscribed = false ;
430437 this . emit ( RoomEvent . TrackUnsubscribed , track , publication , participant ) ;
431438 } catch ( e : unknown ) {
432- console . warn ( `RoomEvent.TrackUnsubscribed: ${ ( e as Error ) . message } ` ) ;
439+ log . warn ( `RoomEvent.TrackUnsubscribed: ${ ( e as Error ) . message } ` ) ;
433440 }
434441 } else if ( ev . case == 'trackSubscriptionFailed' ) {
435442 try {
@@ -441,7 +448,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
441448 ev . value . error ,
442449 ) ;
443450 } catch ( e : unknown ) {
444- console . warn ( `RoomEvent.TrackSubscriptionFailed: ${ ( e as Error ) . message } ` ) ;
451+ log . warn ( `RoomEvent.TrackSubscriptionFailed: ${ ( e as Error ) . message } ` ) ;
445452 }
446453 } else if ( ev . case == 'trackMuted' ) {
447454 try {
@@ -455,7 +462,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
455462 }
456463 this . emit ( RoomEvent . TrackMuted , publication , participant ) ;
457464 } catch ( e : unknown ) {
458- console . warn ( `RoomEvent.TrackMuted: ${ ( e as Error ) . message } ` ) ;
465+ log . warn ( `RoomEvent.TrackMuted: ${ ( e as Error ) . message } ` ) ;
459466 }
460467 } else if ( ev . case == 'trackUnmuted' ) {
461468 try {
@@ -469,7 +476,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
469476 }
470477 this . emit ( RoomEvent . TrackUnmuted , publication , participant ) ;
471478 } catch ( e : unknown ) {
472- console . warn ( `RoomEvent.TrackUnmuted: ${ ( e as Error ) . message } ` ) ;
479+ log . warn ( `RoomEvent.TrackUnmuted: ${ ( e as Error ) . message } ` ) ;
473480 }
474481 } else if ( ev . case == 'activeSpeakersChanged' ) {
475482 try {
@@ -478,7 +485,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
478485 ) ;
479486 this . emit ( RoomEvent . ActiveSpeakersChanged , activeSpeakers ) ;
480487 } catch ( e : unknown ) {
481- console . warn ( `RoomEvent.ActiveSpeakersChanged: ${ ( e as Error ) . message } ` ) ;
488+ log . warn ( `RoomEvent.ActiveSpeakersChanged: ${ ( e as Error ) . message } ` ) ;
482489 }
483490 } else if ( ev . case == 'roomMetadataChanged' ) {
484491 this . info . metadata = ev . value . metadata ?? '' ;
@@ -489,15 +496,15 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
489496 participant . info . metadata = ev . value . metadata ;
490497 this . emit ( RoomEvent . ParticipantMetadataChanged , participant . metadata , participant ) ;
491498 } catch ( e : unknown ) {
492- console . warn ( `RoomEvent.ParticipantMetadataChanged: ${ ( e as Error ) . message } ` ) ;
499+ log . warn ( `RoomEvent.ParticipantMetadataChanged: ${ ( e as Error ) . message } ` ) ;
493500 }
494501 } else if ( ev . case == 'participantNameChanged' ) {
495502 try {
496503 const participant = this . requireParticipantByIdentity ( ev . value . participantIdentity ! ) ;
497504 participant . info . name = ev . value . name ;
498505 this . emit ( RoomEvent . ParticipantNameChanged , participant . name ! , participant ) ;
499506 } catch ( e : unknown ) {
500- console . warn ( `RoomEvent.ParticipantNameChanged: ${ ( e as Error ) . message } ` ) ;
507+ log . warn ( `RoomEvent.ParticipantNameChanged: ${ ( e as Error ) . message } ` ) ;
501508 }
502509 } else if ( ev . case == 'participantAttributesChanged' ) {
503510 try {
@@ -520,14 +527,14 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
520527 this . emit ( RoomEvent . ParticipantAttributesChanged , changedAttributes , participant ) ;
521528 }
522529 } catch ( e : unknown ) {
523- console . warn ( `RoomEvent.ParticipantAttributesChanged: ${ ( e as Error ) . message } ` ) ;
530+ log . warn ( `RoomEvent.ParticipantAttributesChanged: ${ ( e as Error ) . message } ` ) ;
524531 }
525532 } else if ( ev . case == 'connectionQualityChanged' ) {
526533 try {
527534 const participant = this . requireParticipantByIdentity ( ev . value . participantIdentity ! ) ;
528535 this . emit ( RoomEvent . ConnectionQualityChanged , ev . value . quality ! , participant ) ;
529536 } catch ( e : unknown ) {
530- console . warn ( `RoomEvent.ConnectionQualityChanged: ${ ( e as Error ) . message } ` ) ;
537+ log . warn ( `RoomEvent.ConnectionQualityChanged: ${ ( e as Error ) . message } ` ) ;
531538 }
532539 } else if ( ev . case == 'chatMessage' ) {
533540 const participant = this . retrieveParticipantByIdentity ( ev . value . participantIdentity ! ) ;
@@ -612,7 +619,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
612619 participant ,
613620 ) ;
614621 } catch ( e : unknown ) {
615- console . warn ( `RoomEvent.ParticipantEncryptionStatusChanged: ${ ( e as Error ) . message } ` ) ;
622+ log . warn ( `RoomEvent.ParticipantEncryptionStatusChanged: ${ ( e as Error ) . message } ` ) ;
616623 }
617624 }
618625 } ;
0 commit comments