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

Commit ced1e94

Browse files
committed
Add console logs
1 parent e8f4e83 commit ced1e94

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

assets/src/features/streaming/StreamingErrorBoundary.tsx

+26-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { FC, PropsWithChildren, useCallback, useEffect, useState } from "react";
22
import useToast from "../shared/hooks/useToast";
33
import { ErrorMessage, messageComparator } from "../../pages/room/errorMessage";
4-
import { useClient } from "../../fishjam";
4+
import { PeerMetadata, TrackMetadata, useClient } from "../../fishjam";
55
import useEffectOnChange from "../shared/hooks/useEffectOnChange";
6+
import { MessageEvents } from "@fishjam-dev/react-client";
67

78
export const StreamingErrorBoundary: FC<PropsWithChildren> = ({ children }) => {
89
const { addToast } = useToast();
@@ -23,36 +24,55 @@ export const StreamingErrorBoundary: FC<PropsWithChildren> = ({ children }) => {
2324
useEffect(() => {
2425
if (!client) return;
2526

26-
const onSocketError = (_: Event) => {
27+
const onSocketError: MessageEvents<PeerMetadata, TrackMetadata>["socketError"] = (error) => {
28+
console.error("onSocketError");
29+
console.error(error);
2730
handleError(`Socket error occurred.`, "onSocketError");
2831
};
2932

30-
const onConnectionError = (message: string) => {
33+
const onConnectionError: MessageEvents<PeerMetadata, TrackMetadata>["connectionError"] = (message: string) => {
34+
console.error("onConnectionError");
35+
console.error(message);
3136
handleError(`Connection error occurred. ${message ?? ""}`);
3237
};
33-
const onJoinError = (_: unknown) => {
38+
39+
const onJoinError: MessageEvents<PeerMetadata, TrackMetadata>["joinError"] = (error) => {
40+
console.error("onJoinError");
41+
console.error(error);
3442
handleError(`Failed to join the room`);
3543
};
36-
const onAuthError = () => {
44+
45+
const onAuthError: MessageEvents<PeerMetadata, TrackMetadata>["authError"] = (error) => {
46+
console.error("authError");
47+
console.error(error);
3748
handleError(`Socket error occurred.`, "onAuthError");
3849
};
3950

40-
const onSocketClose = (_: Event) => {
51+
const onSocketClose: MessageEvents<PeerMetadata, TrackMetadata>["socketClose"] = (error) => {
52+
console.error("socketClose");
53+
console.error(error);
4154
handleError(`Signaling socket closed.`, "onSocketClose");
4255
};
4356

57+
const error = (error: any) => {
58+
console.error("error");
59+
console.error(error);
60+
};
61+
4462
client.on("socketError", onSocketError);
4563
client.on("connectionError", onConnectionError);
4664
client.on("joinError", onJoinError);
4765
client.on("authError", onAuthError);
4866
client.on("socketClose", onSocketClose);
67+
client.on("error", error);
4968

5069
return () => {
5170
client.off("socketError", onSocketError);
5271
client.off("connectionError", onConnectionError);
5372
client.off("joinError", onJoinError);
5473
client.off("authError", onAuthError);
5574
client.off("socketClose", onSocketClose);
75+
client.off("error", error);
5676
};
5777
}, [client, handleError]);
5878

0 commit comments

Comments
 (0)