feat: integrate Socket.IO for real-time communication; add socket connection management and token refresh handling

This commit is contained in:
JSC
2025-07-27 13:44:00 +02:00
parent 6018a5c8c5
commit 5892d02e9f
10 changed files with 421 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
import { API_CONFIG } from './config'
import { createApiError, NetworkError, TimeoutError } from './errors'
import type { ApiClient, ApiRequestConfig, HttpMethod } from './types'
import { authEvents, AUTH_EVENTS } from '../events'
export class BaseApiClient implements ApiClient {
private refreshPromise: Promise<void> | null = null
@@ -147,6 +148,9 @@ export class BaseApiClient implements ApiClient {
if (!response.ok) {
throw createApiError(response, await this.safeParseJSON(response))
}
// Emit token refresh event for socket reconnection (reactive refresh)
authEvents.emit(AUTH_EVENTS.TOKEN_REFRESHED)
}
private handleAuthenticationFailure(): void {