diff --git a/assets/src/features/streaming/StreamingErrorBoundary.tsx b/assets/src/features/streaming/StreamingErrorBoundary.tsx index c07dda4..3dbaec2 100644 --- a/assets/src/features/streaming/StreamingErrorBoundary.tsx +++ b/assets/src/features/streaming/StreamingErrorBoundary.tsx @@ -3,6 +3,7 @@ import useToast from "../shared/hooks/useToast"; import { ErrorMessage, messageComparator } from "../../pages/room/errorMessage"; import { useClient } from "../../fishjam"; import useEffectOnChange from "../shared/hooks/useEffectOnChange"; +import { MessageEvents } from "@fishjam-dev/ts-client/dist/src/FishjamClient"; 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["onSocketError"] = (error) => { + console.error("onSocketError"); + console.error(error); handleError(`Socket error occurred.`, "onSocketError"); }; - const onConnectionError = (message: string) => { + const onConnectionError: MessageEvents["onConnectionError"] = (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]);