refactor(WebSocket): migrate from SSE to WebSocket for real-time messaging
- Replaced SSEClient with WSClient for handling real-time messaging. - Updated ProcessMessageUseCase to initialize WebSocket listeners. - Refactored messageService to prioritize WebSocket for sending messages, with fallback to HTTP. - Removed sseService and adjusted imports across the application to utilize wsService. - Enhanced message handling and connection management for improved performance and reliability.
This commit is contained in:
@@ -20,7 +20,7 @@ const getBaseUrl = () => {
|
||||
};
|
||||
|
||||
const BASE_URL = getBaseUrl();
|
||||
const SSE_URL = `${BASE_URL.replace(/\/+$/, '')}/realtime/sse`;
|
||||
const WS_URL = `${BASE_URL.replace(/^https?:\/\//, 'wss://').replace(/\/api\/v1$/, '/api/v1')}/realtime/ws`;
|
||||
|
||||
// Token 存储键
|
||||
const TOKEN_KEY = 'auth_token';
|
||||
@@ -441,4 +441,4 @@ class ApiClient {
|
||||
// 导出 API 客户端实例
|
||||
export const api = new ApiClient(BASE_URL);
|
||||
|
||||
export { SSE_URL, TOKEN_KEY, REFRESH_TOKEN_KEY };
|
||||
export { WS_URL, TOKEN_KEY, REFRESH_TOKEN_KEY };
|
||||
|
||||
Reference in New Issue
Block a user