MCPcopy Create free account
hub / github.com/astercloud/aster / initWebSocket

Function initWebSocket

ui/src/composables/useAsterClient.ts:191–217  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

189
190 // 初始化 WebSocket
191 const initWebSocket = async () => {
192 try {
193 // 构建 WebSocket URL
194 const wsUrl = wsUrlEnv || baseUrl.replace(/^http/, "ws") + "/v1/ws";
195
196 ws.value = new WebSocketClient({
197 maxReconnectAttempts: 5,
198 reconnectDelay: 1000,
199 heartbeatInterval: 30000,
200 });
201
202 await ws.value.connect(wsUrl);
203 isConnected.value = true;
204
205 // 设置全局 WebSocket 实例,供 approvalStore 等使用
206 setGlobalWebSocket(ws.value as any);
207
208 subscriptionManager.value = new SubscriptionManager(ws.value as any);
209
210 console.log("✅ Aster WebSocket connected to", wsUrl);
211 console.log("✅ ws.value:", ws.value);
212 console.log("✅ isConnected.value:", isConnected.value);
213 } catch (error) {
214 console.error("❌ Failed to connect WebSocket:", error);
215 isConnected.value = false;
216 }
217 };
218
219 const ensureWebSocket = async () => {
220 if (!ws.value || isConnected.value === false) {

Callers 1

ensureWebSocketFunction · 0.85

Calls 3

setGlobalWebSocketFunction · 0.90
logMethod · 0.80
connectMethod · 0.45

Tested by

no test coverage detected