asab_webui_shell 27.2.2 → 27.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -41,6 +41,8 @@ class AttentionRequiredService extends _asab_webui_components.Service {
|
|
|
41
41
|
this.beaconWebSocket.onopen = () => {
|
|
42
42
|
this.connectionStatus('online');
|
|
43
43
|
console.log('Beacon WebSocket connection established.');
|
|
44
|
+
// Reset reconnection interval on successful connection
|
|
45
|
+
this.reconnectInterval = 5000;
|
|
44
46
|
};
|
|
45
47
|
this.beaconWebSocket.onmessage = message => {
|
|
46
48
|
try {
|
|
@@ -54,10 +56,10 @@ class AttentionRequiredService extends _asab_webui_components.Service {
|
|
|
54
56
|
};
|
|
55
57
|
this.beaconWebSocket.onerror = error => {
|
|
56
58
|
console.error("Beacon WebSocket error:", error);
|
|
57
|
-
console.error("Beacon WebSocket
|
|
59
|
+
console.error("Beacon WebSocket will attempt to reconnect...");
|
|
58
60
|
this.connectionStatus('offline');
|
|
59
61
|
this.distributeData({});
|
|
60
|
-
|
|
62
|
+
// onerror is always followed by onclose, so there is no need to reconnect here, since the reconnection happens in onclose
|
|
61
63
|
};
|
|
62
64
|
this.beaconWebSocket.onclose = () => {
|
|
63
65
|
this.connectionStatus('offline');
|
|
@@ -66,25 +68,16 @@ class AttentionRequiredService extends _asab_webui_components.Service {
|
|
|
66
68
|
leaves the application (not the screen).
|
|
67
69
|
*/
|
|
68
70
|
if (this.beaconWebSocket) {
|
|
69
|
-
// Close the WebSocket connection
|
|
70
|
-
this.beaconWebSocket.close();
|
|
71
|
-
|
|
72
|
-
// Clean up event listeners
|
|
73
71
|
this.beaconWebSocket.onopen = null;
|
|
74
72
|
this.beaconWebSocket.onmessage = null;
|
|
75
73
|
this.beaconWebSocket.onerror = null;
|
|
76
74
|
this.beaconWebSocket.onclose = null;
|
|
77
|
-
|
|
78
|
-
// Set WebSocket reference to null to free up memory
|
|
79
75
|
this.beaconWebSocket = null;
|
|
80
76
|
}
|
|
81
77
|
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this.reconnectTimeout = null;
|
|
86
|
-
}
|
|
87
|
-
console.log("Beacon WebSocket connection closed.");
|
|
78
|
+
// Service should maintain connection throughout the application lifecycle.
|
|
79
|
+
console.log("Beacon WebSocket connection closed. Attempting to reconnect...");
|
|
80
|
+
this.reconnectBeaconWebSocket();
|
|
88
81
|
};
|
|
89
82
|
}
|
|
90
83
|
|
|
@@ -37,6 +37,8 @@ export default class AttentionRequiredService extends Service {
|
|
|
37
37
|
this.beaconWebSocket.onopen = () => {
|
|
38
38
|
this.connectionStatus('online');
|
|
39
39
|
console.log('Beacon WebSocket connection established.');
|
|
40
|
+
// Reset reconnection interval on successful connection
|
|
41
|
+
this.reconnectInterval = 5000;
|
|
40
42
|
};
|
|
41
43
|
|
|
42
44
|
this.beaconWebSocket.onmessage = (message) => {
|
|
@@ -52,10 +54,10 @@ export default class AttentionRequiredService extends Service {
|
|
|
52
54
|
|
|
53
55
|
this.beaconWebSocket.onerror = (error) => {
|
|
54
56
|
console.error("Beacon WebSocket error:", error);
|
|
55
|
-
console.error("Beacon WebSocket
|
|
57
|
+
console.error("Beacon WebSocket will attempt to reconnect...");
|
|
56
58
|
this.connectionStatus('offline');
|
|
57
59
|
this.distributeData({});
|
|
58
|
-
|
|
60
|
+
// onerror is always followed by onclose, so there is no need to reconnect here, since the reconnection happens in onclose
|
|
59
61
|
};
|
|
60
62
|
|
|
61
63
|
this.beaconWebSocket.onclose = () => {
|
|
@@ -65,26 +67,17 @@ export default class AttentionRequiredService extends Service {
|
|
|
65
67
|
leaves the application (not the screen).
|
|
66
68
|
*/
|
|
67
69
|
if (this.beaconWebSocket) {
|
|
68
|
-
// Close the WebSocket connection
|
|
69
|
-
this.beaconWebSocket.close();
|
|
70
|
-
|
|
71
|
-
// Clean up event listeners
|
|
72
70
|
this.beaconWebSocket.onopen = null;
|
|
73
71
|
this.beaconWebSocket.onmessage = null;
|
|
74
72
|
this.beaconWebSocket.onerror = null;
|
|
75
73
|
this.beaconWebSocket.onclose = null;
|
|
76
|
-
|
|
77
|
-
// Set WebSocket reference to null to free up memory
|
|
78
74
|
this.beaconWebSocket = null;
|
|
79
75
|
}
|
|
80
76
|
|
|
81
|
-
// Clear the reconnect timeout if it exists
|
|
82
|
-
if (this.reconnectTimeout) {
|
|
83
|
-
clearTimeout(this.reconnectTimeout);
|
|
84
|
-
this.reconnectTimeout = null;
|
|
85
|
-
}
|
|
86
77
|
|
|
87
|
-
|
|
78
|
+
// Service should maintain connection throughout the application lifecycle.
|
|
79
|
+
console.log("Beacon WebSocket connection closed. Attempting to reconnect...");
|
|
80
|
+
this.reconnectBeaconWebSocket();
|
|
88
81
|
};
|
|
89
82
|
}
|
|
90
83
|
|