Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlolka1333 <xtrafcyz@gmail.com>2026-01-18 17:38:57 +0300
committerGitHub <noreply@github.com>2026-01-18 17:38:57 +0300
commit77fa976ee9d6ad529adc96e8826dc56eaedf061d (patch)
treea565d25e69c756acb752ddad710f01707228633a /web/assets/js/websocket.js
parent8098d2b1b1c028e4f3d220cc27f43c7a70115a0e (diff)
Enhance WebSocket client connection logic and improve event listener management (#3636)
- Updated WebSocketClient to allow connection during CONNECTING state. - Introduced a flag for reconnection attempts. - Improved event listener registration to prevent duplicate callbacks. - Refactored online clients update logic in inbounds.html for better performance and clarity. - Added CSS styles for subscription link boxes in subpage.html to enhance UI consistency and interactivity. Co-authored-by: lolka1333 <test123@gmail.com>
Diffstat (limited to 'web/assets/js/websocket.js')
-rw-r--r--web/assets/js/websocket.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/web/assets/js/websocket.js b/web/assets/js/websocket.js
index 5b8a3948..ccafef87 100644
--- a/web/assets/js/websocket.js
+++ b/web/assets/js/websocket.js
@@ -14,10 +14,12 @@ class WebSocketClient {
}
connect() {
- if (this.ws && this.ws.readyState === WebSocket.OPEN) {
+ if (this.ws && (this.ws.readyState === WebSocket.OPEN || this.ws.readyState === WebSocket.CONNECTING)) {
return;
}
+ this.shouldReconnect = true;
+
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
// Ensure basePath ends with '/' for proper URL construction
let basePath = this.basePath || '';
@@ -97,7 +99,10 @@ class WebSocketClient {
if (!this.listeners.has(event)) {
this.listeners.set(event, []);
}
- this.listeners.get(event).push(callback);
+ const callbacks = this.listeners.get(event);
+ if (!callbacks.includes(callback)) {
+ callbacks.push(callback);
+ }
}
off(event, callback) {