import { useMemo } from 'react' ; import { useWebSocket as _useWebSocket } from './lib/use-websocket/use-websocket' ; import { DEFAULT_OPTIONS } from './lib/use-websocket/config' ; import { Options , SendMessage } from './lib/use-websocket/types' ; import { ReadyState } from './lib/use-websocket/globals' ; import Config from '@/config' ; import { getToken } from '@/lin/utils/token' ; export { Options , SendMessage , ReadyState } ; const MAIN_URL = `${ Config . baseWebSocketURL }/ws/message?token=${ getToken ( 'access_token' ) ?. split ( ' ' ) [ 1 ] }` ; const MAIN_OPTIONS = { shouldReconnect : true } ; export const useWebSocket = ( ... args ) => { const url = args [ 0 ] || MAIN_URL || null ; const options = useMemo ( ( ) => { return Object . assign ( DEFAULT_OPTIONS , args [ 1 ] || MAIN_OPTIONS ) ; } , [ ] ) ; return _useWebSocket ( url , options ) ; } ;