fix: improve maintenance and synchronize live conversations
This commit is contained in:
1 parent
bb541bd212
commit
ef86a5d3af
297 files changed
+2983
-1274
No files matched your search
@@ -34,7 +34,15 @@ class SocketService {
|
||||
}
|
||||
|
||||
connect(namespace: string = '/agent') {
|
||||
if (this.socket?.connected) return
|
||||
if (this.socket) {
|
||||
// Socket.IO keeps the same instance while its manager reconnects. Reuse
|
||||
// that instance so existing event subscriptions survive the reconnect
|
||||
// window and repeated callers cannot orphan a pending socket.
|
||||
if (!this.socket.connected && !this.socket.active) {
|
||||
this.socket.connect()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Use the runtime-resolved WS URL (window.APP_CONFIG → VITE_WS_URL → localhost),
|
||||
// same as every other consumer. Reading import.meta.env directly baked the
|
||||
@@ -76,12 +84,13 @@ class SocketService {
|
||||
}
|
||||
}
|
||||
|
||||
emit(event: string, data: unknown) {
|
||||
emit(event: string, data: unknown, acknowledge?: () => void) {
|
||||
if (!this.socket) {
|
||||
console.error('Socket not initialized')
|
||||
return
|
||||
}
|
||||
this.socket.emit(event, data)
|
||||
if (acknowledge) this.socket.emit(event, data, acknowledge)
|
||||
else this.socket.emit(event, data)
|
||||
}
|
||||
|
||||
emitPing(event: string) {
|
||||
|
||||
Reference in new issue
Block a user