SHA256
fix(call): корректный mute, статус прямое/TURN и реавторизация WS
This commit is contained in:
+45
-1
@@ -119,6 +119,7 @@ let connectionRetryBannerEl = null;
|
||||
let connectionStatusCountdownId = null;
|
||||
let connectionNextRetryAtMs = 0;
|
||||
let connectionCheckInFlight = false;
|
||||
let wsSessionRestoreInFlight = null;
|
||||
|
||||
setClientErrorTransport((payload) => authService.reportClientError(payload));
|
||||
initPwaInstallPromptHandling();
|
||||
@@ -286,8 +287,15 @@ async function checkConnectionHealth() {
|
||||
setConnectionStatus('connecting');
|
||||
}
|
||||
try {
|
||||
if (!wsIsOpen()) {
|
||||
const wasOpen = wsIsOpen();
|
||||
if (!wasOpen) {
|
||||
await authService.ws.open();
|
||||
const restored = await ensureSessionAfterWsReconnect();
|
||||
if (!restored) {
|
||||
connectionStatusText = '';
|
||||
setConnectionStatus('disconnected');
|
||||
return;
|
||||
}
|
||||
}
|
||||
await authService.ws.request('Ping', { ts: Date.now() }, 7000);
|
||||
setConnectionStatus('connected');
|
||||
@@ -327,6 +335,40 @@ function wsIsOpen() {
|
||||
return !!(ws && ws.readyState === WebSocket.OPEN);
|
||||
}
|
||||
|
||||
async function ensureSessionAfterWsReconnect() {
|
||||
if (!state.session.isAuthorized) return true;
|
||||
if (wsSessionRestoreInFlight) return wsSessionRestoreInFlight;
|
||||
|
||||
wsSessionRestoreInFlight = (async () => {
|
||||
try {
|
||||
const resumed = await authService.resumeSession(state.session.login, state.session.sessionId);
|
||||
authorizeSession({
|
||||
login: resumed.login || state.session.login,
|
||||
sessionId: resumed.sessionId || state.session.sessionId,
|
||||
storagePwd: resumed.storagePwd || state.session.storagePwdInMemory,
|
||||
});
|
||||
addAppLogEntry({
|
||||
level: 'info',
|
||||
source: 'ws-reconnect',
|
||||
message: 'Сессия восстановлена после переподключения WS',
|
||||
});
|
||||
return true;
|
||||
} catch (error) {
|
||||
if (isSessionInvalidError(error)) {
|
||||
await terminateCurrentSession({
|
||||
infoMessage: 'Ваша сессия устарела. Авторизируйтесь заново.',
|
||||
});
|
||||
return false;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
})().finally(() => {
|
||||
wsSessionRestoreInFlight = null;
|
||||
});
|
||||
|
||||
return wsSessionRestoreInFlight;
|
||||
}
|
||||
|
||||
function showGlobalErrorAlert(title, details = {}) {
|
||||
const lines = [title];
|
||||
if (details.message) lines.push(`Сообщение: ${details.message}`);
|
||||
@@ -533,6 +575,8 @@ async function ensureSessionRuntimeStarted() {
|
||||
|
||||
try {
|
||||
await authService.ws.open();
|
||||
const restored = await ensureSessionAfterWsReconnect();
|
||||
if (!restored) return;
|
||||
addAppLogEntry({
|
||||
level: 'info',
|
||||
source: 'ws-reconnect',
|
||||
|
||||
Reference in New Issue
Block a user