This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { useCallback, useEffect, useRef } from 'react';
|
||||
import { type ChatMessage } from '../api';
|
||||
import { type ChatMessage, getWsUrl } from '../api';
|
||||
import { useAuth } from '../auth/AuthContext';
|
||||
import { playChatSound } from '../utils/notifySound';
|
||||
|
||||
@@ -28,8 +28,7 @@ export function StaffChatSocket() {
|
||||
useEffect(() => {
|
||||
if (!token || !staff?.id) return;
|
||||
|
||||
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
const wsUrl = `${protocol}//${window.location.hostname}:8080/ws?role=teacher&staffId=${staff.id}`;
|
||||
const wsUrl = getWsUrl(`/ws?role=teacher&staffId=${staff.id}`);
|
||||
let ws: WebSocket | null = null;
|
||||
let retryTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
let closed = false;
|
||||
|
||||
Reference in New Issue
Block a user