diff --git a/.changeset/cyan-yaks-wink.md b/.changeset/cyan-yaks-wink.md new file mode 100644 index 000000000..33c1e24a0 --- /dev/null +++ b/.changeset/cyan-yaks-wink.md @@ -0,0 +1,5 @@ +--- +"@livekit/components-react": patch +--- + +Surface encryption error on LiveKitRoom diff --git a/packages/react/etc/components-react.api.md b/packages/react/etc/components-react.api.md index 9458951c9..e9b78a19e 100644 --- a/packages/react/etc/components-react.api.md +++ b/packages/react/etc/components-react.api.md @@ -312,6 +312,8 @@ export interface LiveKitRoomProps extends Omit void; // (undocumented) + onEncryptionError?: (error: Error) => void; + // (undocumented) onError?: (error: Error) => void; // (undocumented) onMediaDeviceFailure?: (failure?: MediaDeviceFailure) => void; diff --git a/packages/react/src/components/LiveKitRoom.tsx b/packages/react/src/components/LiveKitRoom.tsx index 5626c7e7f..2410cacc3 100644 --- a/packages/react/src/components/LiveKitRoom.tsx +++ b/packages/react/src/components/LiveKitRoom.tsx @@ -67,6 +67,7 @@ export interface LiveKitRoomProps extends Omit void; onError?: (error: Error) => void; onMediaDeviceFailure?: (failure?: MediaDeviceFailure) => void; + onEncryptionError?: (error: Error) => void; /** * Optional room instance. * By passing your own room instance you overwrite the `options` parameter, diff --git a/packages/react/src/hooks/useLiveKitRoom.ts b/packages/react/src/hooks/useLiveKitRoom.ts index 927b1e009..6fa161142 100644 --- a/packages/react/src/hooks/useLiveKitRoom.ts +++ b/packages/react/src/hooks/useLiveKitRoom.ts @@ -43,6 +43,7 @@ export function useLiveKitRoom( onDisconnected, onError, onMediaDeviceFailure, + onEncryptionError, simulateParticipants, ...rest } = { ...defaultRoomProps, ...props }; @@ -79,18 +80,25 @@ export function useLiveKitRoom( }); }; - const onMediaDeviceError = (e: Error) => { + const handleMediaDeviceError = (e: Error) => { const mediaDeviceFailure = MediaDeviceFailure.getFailure(e); onMediaDeviceFailure?.(mediaDeviceFailure); }; - room.on(RoomEvent.SignalConnected, onSignalConnected); - room.on(RoomEvent.MediaDevicesError, onMediaDeviceError); + const handleEncryptionError = (e: Error) => { + onEncryptionError?.(e); + }; + room + .on(RoomEvent.SignalConnected, onSignalConnected) + .on(RoomEvent.MediaDevicesError, handleMediaDeviceError) + .on(RoomEvent.EncryptionError, handleEncryptionError); return () => { - room.off(RoomEvent.SignalConnected, onSignalConnected); - room.off(RoomEvent.MediaDevicesError, onMediaDeviceError); + room + .off(RoomEvent.SignalConnected, onSignalConnected) + .off(RoomEvent.MediaDevicesError, handleMediaDeviceError) + .off(RoomEvent.EncryptionError, handleEncryptionError); }; - }, [room, audio, video, screen, onError]); + }, [room, audio, video, screen, onError, onEncryptionError, onMediaDeviceFailure]); React.useEffect(() => { if (!room) return;