jsgar 3.1.0 → 3.1.2
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 +42 -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) {
|
|
@@ -713,6 +742,7 @@
|
|
|
713
742
|
* @param {number} [snapshotSizeLimit=0] - Limit snapshot size
|
|
714
743
|
* @param {number} [nagleInterval=0] - Nagle interval in milliseconds
|
|
715
744
|
* @param {number} [limit=0] - Limits records in initial snapshot (0 = all)
|
|
745
|
+
* @param {boolean} [trimDefaultValues=false] - Trim records containing default values from the snapshot
|
|
716
746
|
*/
|
|
717
747
|
subscribe(
|
|
718
748
|
name,
|
|
@@ -728,6 +758,7 @@
|
|
|
728
758
|
includeReferencedKeys = false,
|
|
729
759
|
includeReferencingKeys = false,
|
|
730
760
|
includeAllNamespace = false,
|
|
761
|
+
trimDefaultValues = false,
|
|
731
762
|
workingNamespace = null,
|
|
732
763
|
density = null,
|
|
733
764
|
subscriptionGroup = 0,
|
|
@@ -812,6 +843,9 @@
|
|
|
812
843
|
if (includeAllNamespace) {
|
|
813
844
|
valueDict.include_all_namespace = includeAllNamespace;
|
|
814
845
|
}
|
|
846
|
+
if (trimDefaultValues) {
|
|
847
|
+
valueDict.trim_default_values = trimDefaultValues;
|
|
848
|
+
}
|
|
815
849
|
if (limit > 0) {
|
|
816
850
|
valueDict.limit = limit;
|
|
817
851
|
}
|
|
@@ -884,6 +918,7 @@
|
|
|
884
918
|
false,
|
|
885
919
|
false,
|
|
886
920
|
false,
|
|
921
|
+
false,
|
|
887
922
|
null,
|
|
888
923
|
null,
|
|
889
924
|
subscriptionGroup,
|