diff --git a/assets/src/features/streaming/StreamingErrorBoundary.tsx b/assets/src/features/streaming/StreamingErrorBoundary.tsx index c07dda4..f2b51f7 100644 --- a/assets/src/features/streaming/StreamingErrorBoundary.tsx +++ b/assets/src/features/streaming/StreamingErrorBoundary.tsx @@ -1,8 +1,9 @@ import { FC, PropsWithChildren, useCallback, useEffect, useState } from "react"; import useToast from "../shared/hooks/useToast"; import { ErrorMessage, messageComparator } from "../../pages/room/errorMessage"; -import { useClient } from "../../fishjam"; +import { PeerMetadata, TrackMetadata, useClient } from "../../fishjam"; import useEffectOnChange from "../shared/hooks/useEffectOnChange"; +import { MessageEvents } from "@fishjam-dev/react-client"; export const StreamingErrorBoundary: FC = ({ children }) => { const { addToast } = useToast(); @@ -23,29 +24,47 @@ export const StreamingErrorBoundary: FC = ({ children }) => { useEffect(() => { if (!client) return; - const onSocketError = (_: Event) => { + const onSocketError: MessageEvents["socketError"] = (error) => { + console.error("onSocketError"); + console.error(error); handleError(`Socket error occurred.`, "onSocketError"); }; - const onConnectionError = (message: string) => { + const onConnectionError: MessageEvents["connectionError"] = (message: string) => { + console.error("onConnectionError"); + console.error(message); handleError(`Connection error occurred. ${message ?? ""}`); }; - const onJoinError = (_: unknown) => { + + const onJoinError: MessageEvents["joinError"] = (error) => { + console.error("onJoinError"); + console.error(error); handleError(`Failed to join the room`); }; - const onAuthError = () => { + + const onAuthError: MessageEvents["authError"] = (error) => { + console.error("authError"); + console.error(error); handleError(`Socket error occurred.`, "onAuthError"); }; - const onSocketClose = (_: Event) => { + const onSocketClose: MessageEvents["socketClose"] = (error) => { + console.error("socketClose"); + console.error(error); handleError(`Signaling socket closed.`, "onSocketClose"); }; + const error = (error: any) => { + console.error("error"); + console.error(error); + }; + client.on("socketError", onSocketError); client.on("connectionError", onConnectionError); client.on("joinError", onJoinError); client.on("authError", onAuthError); client.on("socketClose", onSocketClose); + client.on("error", error); return () => { client.off("socketError", onSocketError); @@ -53,6 +72,7 @@ export const StreamingErrorBoundary: FC = ({ children }) => { client.off("joinError", onJoinError); client.off("authError", onAuthError); client.off("socketClose", onSocketClose); + client.off("error", error); }; }, [client, handleError]);