jsgar 3.1.0 → 3.1.1
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.
- package/dist/gar.umd.js +36 -7
- package/package.json +1 -1
package/dist/gar.umd.js
CHANGED
|
@@ -64,25 +64,23 @@
|
|
|
64
64
|
this.serverTopicNameToId = new Map();
|
|
65
65
|
this.serverKeyIdToName = new Map();
|
|
66
66
|
this.serverKeyNameToId = new Map();
|
|
67
|
-
this.localTopicCounter = 1;
|
|
68
|
-
this.localKeyCounter = 1;
|
|
69
67
|
this.localTopicMap = new Map();
|
|
70
68
|
this.localKeyMap = new Map();
|
|
69
|
+
this.recordMap = new Map();
|
|
71
70
|
|
|
72
71
|
this.running = false;
|
|
73
72
|
this.heartbeatIntervalId = null;
|
|
74
73
|
this.messageHandlers = new Map();
|
|
75
74
|
this.lastHeartbeatTime = Date.now() / 1000;
|
|
76
75
|
this.heartbeatTimeout = 3; // Seconds
|
|
77
|
-
this._initialGracePeriod = false;
|
|
78
|
-
this._initialGraceDeadline = 0;
|
|
79
76
|
|
|
80
77
|
this.heartbeatTimeoutCallback = null;
|
|
81
78
|
this.stoppedCallback = null;
|
|
82
|
-
this.recordMap = new Map();
|
|
83
79
|
this.allowSelfSignedCertificate = allowSelfSignedCertificate;
|
|
84
80
|
this.exitCode = 0;
|
|
85
81
|
|
|
82
|
+
this.clearConnectionState();
|
|
83
|
+
|
|
86
84
|
// Initialize log levels and set logLevel
|
|
87
85
|
this.logLevels = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'];
|
|
88
86
|
this.logLevel = logLevel.toUpperCase();
|
|
@@ -91,8 +89,6 @@
|
|
|
91
89
|
this.logLevel = 'INFO';
|
|
92
90
|
}
|
|
93
91
|
|
|
94
|
-
this.activeSubscriptionGroup = 0;
|
|
95
|
-
|
|
96
92
|
this.registerDefaultHandlers();
|
|
97
93
|
}
|
|
98
94
|
|
|
@@ -114,10 +110,43 @@
|
|
|
114
110
|
}
|
|
115
111
|
}
|
|
116
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Reset all connection-related state:
|
|
115
|
+
* server/client topic/key mappings, counters, grace flags, and records.
|
|
116
|
+
*/
|
|
117
|
+
clearConnectionState() {
|
|
118
|
+
// Server assigned topic/key <-> name mappings
|
|
119
|
+
this.serverTopicIdToName.clear();
|
|
120
|
+
this.serverTopicNameToId.clear();
|
|
121
|
+
this.serverKeyIdToName.clear();
|
|
122
|
+
this.serverKeyNameToId.clear();
|
|
123
|
+
|
|
124
|
+
// Client assigned topic/key counters and name <-> ID maps
|
|
125
|
+
this.localTopicCounter = 1;
|
|
126
|
+
this.localKeyCounter = 1;
|
|
127
|
+
this.localTopicMap.clear();
|
|
128
|
+
this.localKeyMap.clear();
|
|
129
|
+
|
|
130
|
+
// Heartbeat grace period flags
|
|
131
|
+
this._initialGracePeriod = false;
|
|
132
|
+
this._initialGraceDeadline = 0;
|
|
133
|
+
|
|
134
|
+
// Cached records
|
|
135
|
+
this.recordMap.clear();
|
|
136
|
+
|
|
137
|
+
this.activeSubscriptionGroup = 0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Establish WebSocket connection with reconnection logic.
|
|
142
|
+
*/
|
|
117
143
|
/**
|
|
118
144
|
* Establish WebSocket connection with reconnection logic.
|
|
119
145
|
*/
|
|
120
146
|
async connect() {
|
|
147
|
+
// Before attempting a new connection, clear any previous state
|
|
148
|
+
this.clearConnectionState();
|
|
149
|
+
|
|
121
150
|
while (this.running && !this.connected) {
|
|
122
151
|
try {
|
|
123
152
|
if (this.allowSelfSignedCertificate) {
|