Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
Add console logs
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil-stasiak committed Jun 5, 2024
1 parent e8f4e83 commit 2c8a9b1
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions assets/src/features/streaming/StreamingErrorBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<PropsWithChildren> = ({ children }) => {
const { addToast } = useToast();
Expand All @@ -23,36 +24,55 @@ export const StreamingErrorBoundary: FC<PropsWithChildren> = ({ 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);
client.off("connectionError", onConnectionError);
client.off("joinError", onJoinError);
client.off("authError", onAuthError);
client.off("socketClose", onSocketClose);
client.off("error", error);
};
}, [client, handleError]);

Expand Down

0 comments on commit 2c8a9b1

Please sign in to comment.