1
1
import { FC , PropsWithChildren , useCallback , useEffect , useState } from "react" ;
2
2
import useToast from "../shared/hooks/useToast" ;
3
3
import { ErrorMessage , messageComparator } from "../../pages/room/errorMessage" ;
4
- import { useClient } from "../../fishjam" ;
4
+ import { PeerMetadata , TrackMetadata , useClient } from "../../fishjam" ;
5
5
import useEffectOnChange from "../shared/hooks/useEffectOnChange" ;
6
+ import { MessageEvents } from "@fishjam-dev/ts-client" ;
6
7
7
8
export const StreamingErrorBoundary : FC < PropsWithChildren > = ( { children } ) => {
8
9
const { addToast } = useToast ( ) ;
@@ -23,21 +24,27 @@ export const StreamingErrorBoundary: FC<PropsWithChildren> = ({ children }) => {
23
24
useEffect ( ( ) => {
24
25
if ( ! client ) return ;
25
26
26
- const onSocketError = ( _ : Event ) => {
27
+ const onSocketError : MessageEvents < PeerMetadata , TrackMetadata > [ "socketError" ] = ( error : Event ) => {
28
+ console . warn ( error ) ;
27
29
handleError ( `Socket error occurred.` , "onSocketError" ) ;
28
30
} ;
29
31
30
- const onConnectionError = ( message : string ) => {
31
- handleError ( `Connection error occurred. ${ message ?? "" } ` ) ;
32
+ const onConnectionError : MessageEvents < PeerMetadata , TrackMetadata > [ "connectionError" ] = ( error ) => {
33
+ console . warn ( error ) ;
34
+ handleError ( `Connection error occurred. ${ error ?. message ?? "" } ` ) ;
32
35
} ;
33
- const onJoinError = ( _ : unknown ) => {
36
+
37
+ const onJoinError : MessageEvents < PeerMetadata , TrackMetadata > [ "joinError" ] = ( event ) => {
38
+ console . log ( event )
34
39
handleError ( `Failed to join the room` ) ;
35
40
} ;
36
- const onAuthError = ( ) => {
41
+ const onAuthError : MessageEvents < PeerMetadata , TrackMetadata > [ "authError" ] = ( reason ) => {
42
+ console . warn ( reason ) ;
37
43
handleError ( `Socket error occurred.` , "onAuthError" ) ;
38
44
} ;
39
45
40
- const onSocketClose = ( _ : Event ) => {
46
+ const onSocketClose : MessageEvents < PeerMetadata , TrackMetadata > [ "socketClose" ] = ( event ) => {
47
+ console . warn ( event ) ;
41
48
handleError ( `Signaling socket closed.` , "onSocketClose" ) ;
42
49
} ;
43
50
0 commit comments