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 ced1e94
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions assets/src/features/streaming/StreamingErrorBoundary.tsx
Original file line number Diff line number Diff line change
@@ -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<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<PeerMetadata, TrackMetadata>["socketError"] = (error) => {
console.error("onSocketError");
console.error(error);
handleError(`Socket error occurred.`, "onSocketError");
};

const onConnectionError = (message: string) => {
const onConnectionError: MessageEvents<PeerMetadata, TrackMetadata>["connectionError"] = (message: string) => {
console.error("onConnectionError");
console.error(message);
handleError(`Connection error occurred. ${message ?? ""}`);
};
const onJoinError = (_: unknown) => {

const onJoinError: MessageEvents<PeerMetadata, TrackMetadata>["joinError"] = (error) => {
console.error("onJoinError");
console.error(error);
handleError(`Failed to join the room`);
};
const onAuthError = () => {

const onAuthError: MessageEvents<PeerMetadata, TrackMetadata>["authError"] = (error) => {
console.error("authError");
console.error(error);
handleError(`Socket error occurred.`, "onAuthError");
};

const onSocketClose = (_: Event) => {
const onSocketClose: MessageEvents<PeerMetadata, TrackMetadata>["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 ced1e94

Please sign in to comment.