Log when a track is unpublished or runs into an error (#3495)
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
|||||||
ConnectionState,
|
ConnectionState,
|
||||||
type E2EEManagerOptions,
|
type E2EEManagerOptions,
|
||||||
ExternalE2EEKeyProvider,
|
ExternalE2EEKeyProvider,
|
||||||
|
type LocalTrackPublication,
|
||||||
LocalVideoTrack,
|
LocalVideoTrack,
|
||||||
Room,
|
Room,
|
||||||
type RoomOptions,
|
type RoomOptions,
|
||||||
@@ -181,6 +182,33 @@ export function useLivekit(
|
|||||||
sfuConfig,
|
sfuConfig,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Log errors when local participant has issues publishing a track.
|
||||||
|
useEffect(() => {
|
||||||
|
const localTrackUnpublishedFn = (
|
||||||
|
publication: LocalTrackPublication,
|
||||||
|
): void => {
|
||||||
|
logger.info(
|
||||||
|
"Local track unpublished",
|
||||||
|
publication.trackName,
|
||||||
|
publication.trackInfo,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
const mediaDevicesErrorFn = (error: Error): void => {
|
||||||
|
logger.warn("Media devices error when publishing a track", error);
|
||||||
|
};
|
||||||
|
|
||||||
|
room.localParticipant.on("localTrackUnpublished", localTrackUnpublishedFn);
|
||||||
|
room.localParticipant.on("mediaDevicesError", mediaDevicesErrorFn);
|
||||||
|
|
||||||
|
return (): void => {
|
||||||
|
room.localParticipant.off(
|
||||||
|
"localTrackUnpublished",
|
||||||
|
localTrackUnpublishedFn,
|
||||||
|
);
|
||||||
|
room.localParticipant.off("mediaDevicesError", mediaDevicesErrorFn);
|
||||||
|
};
|
||||||
|
}, [room.localParticipant]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Sync the requested mute states with LiveKit's mute states. We do it this
|
// Sync the requested mute states with LiveKit's mute states. We do it this
|
||||||
// way around rather than using LiveKit as the source of truth, so that the
|
// way around rather than using LiveKit as the source of truth, so that the
|
||||||
|
|||||||
Reference in New Issue
Block a user