feat: integrate Socket.IO for real-time communication; add socket connection management and token refresh handling
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user