jsgar 4.3.2 → 4.5.0
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 +25 -14
- package/gar.js +25 -14
- package/package.json +1 -1
package/dist/gar.umd.js
CHANGED
|
@@ -73,6 +73,7 @@
|
|
|
73
73
|
this.localTopicMap = new Map();
|
|
74
74
|
this.localKeyMap = new Map();
|
|
75
75
|
this.recordMap = new Map();
|
|
76
|
+
this._activeOwnership = { msg_ref: 0, ownership_action: 'None', skip_ownership_checks: false, client_key_id: 0 };
|
|
76
77
|
|
|
77
78
|
this.running = false;
|
|
78
79
|
this.heartbeatIntervalId = null;
|
|
@@ -138,6 +139,9 @@
|
|
|
138
139
|
this.localTopicMap.clear();
|
|
139
140
|
this.localKeyMap.clear();
|
|
140
141
|
|
|
142
|
+
// Active ownership state
|
|
143
|
+
this._activeOwnership = { msg_ref: 0, ownership_action: 'None', skip_ownership_checks: false, client_key_id: 0 };
|
|
144
|
+
|
|
141
145
|
// Heartbeat grace period flags
|
|
142
146
|
this._initialGracePeriod = false;
|
|
143
147
|
this._initialGraceDeadline = 0;
|
|
@@ -1131,6 +1135,23 @@
|
|
|
1131
1135
|
);
|
|
1132
1136
|
}
|
|
1133
1137
|
|
|
1138
|
+
/**
|
|
1139
|
+
* Send an ActiveOwnership message if the parameters differ from the last sent values.
|
|
1140
|
+
* @param {Object} [options]
|
|
1141
|
+
* @param {number} [options.msgRef=0] - Message reference for correlating recoverable error responses.
|
|
1142
|
+
* @param {string} [options.ownershipAction='None'] - 'None' (check only), 'Acquire', or 'Release'.
|
|
1143
|
+
* @param {boolean} [options.skipOwnershipChecks=false] - Bypass ownership validation.
|
|
1144
|
+
* @param {number} [options.clientKeyId=0] - The g::Client key ID for ownership. 0 uses the connection key.
|
|
1145
|
+
*/
|
|
1146
|
+
updateActiveOwnership({ msgRef = 0, ownershipAction = 'None', skipOwnershipChecks = false, clientKeyId = 0 } = {}) {
|
|
1147
|
+
const newOwnership = { msg_ref: msgRef, ownership_action: ownershipAction, skip_ownership_checks: skipOwnershipChecks, client_key_id: clientKeyId };
|
|
1148
|
+
const cur = this._activeOwnership;
|
|
1149
|
+
if (newOwnership.msg_ref !== cur.msg_ref || newOwnership.ownership_action !== cur.ownership_action || newOwnership.skip_ownership_checks !== cur.skip_ownership_checks || newOwnership.client_key_id !== cur.client_key_id) {
|
|
1150
|
+
this._activeOwnership = newOwnership;
|
|
1151
|
+
this.sendMessage({ message_type: 'ActiveOwnership', value: newOwnership });
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1134
1155
|
/**
|
|
1135
1156
|
* Introduce a new key if not already known and return local key ID.
|
|
1136
1157
|
* @param {string} name - Key name
|
|
@@ -1141,25 +1162,15 @@
|
|
|
1141
1162
|
if (!this.localKeyMap.has(name)) {
|
|
1142
1163
|
const keyId = this.localKeyCounter++;
|
|
1143
1164
|
this.localKeyMap.set(name, keyId);
|
|
1144
|
-
|
|
1165
|
+
const value = { key_id: keyId, name };
|
|
1145
1166
|
if (className) {
|
|
1146
1167
|
if (typeof className === 'string') {
|
|
1147
|
-
|
|
1168
|
+
value.class_list = className.split(/\s+/).filter(Boolean);
|
|
1148
1169
|
} else if (Array.isArray(className)) {
|
|
1149
|
-
|
|
1170
|
+
value.class_list = className;
|
|
1150
1171
|
}
|
|
1151
1172
|
}
|
|
1152
|
-
|
|
1153
|
-
message_type: 'KeyIntroduction',
|
|
1154
|
-
value: {
|
|
1155
|
-
key_id: keyId,
|
|
1156
|
-
name
|
|
1157
|
-
}
|
|
1158
|
-
};
|
|
1159
|
-
if (classList) {
|
|
1160
|
-
msg.value.class_list = classList;
|
|
1161
|
-
}
|
|
1162
|
-
this.sendMessage(msg);
|
|
1173
|
+
this.sendMessage({ message_type: 'KeyIntroduction', value });
|
|
1163
1174
|
}
|
|
1164
1175
|
return this.localKeyMap.get(name);
|
|
1165
1176
|
}
|
package/gar.js
CHANGED
|
@@ -67,6 +67,7 @@ class GARClient {
|
|
|
67
67
|
this.localTopicMap = new Map();
|
|
68
68
|
this.localKeyMap = new Map();
|
|
69
69
|
this.recordMap = new Map();
|
|
70
|
+
this._activeOwnership = { msg_ref: 0, ownership_action: 'None', skip_ownership_checks: false, client_key_id: 0 };
|
|
70
71
|
|
|
71
72
|
this.running = false;
|
|
72
73
|
this.heartbeatIntervalId = null;
|
|
@@ -132,6 +133,9 @@ class GARClient {
|
|
|
132
133
|
this.localTopicMap.clear();
|
|
133
134
|
this.localKeyMap.clear();
|
|
134
135
|
|
|
136
|
+
// Active ownership state
|
|
137
|
+
this._activeOwnership = { msg_ref: 0, ownership_action: 'None', skip_ownership_checks: false, client_key_id: 0 };
|
|
138
|
+
|
|
135
139
|
// Heartbeat grace period flags
|
|
136
140
|
this._initialGracePeriod = false;
|
|
137
141
|
this._initialGraceDeadline = 0;
|
|
@@ -1125,6 +1129,23 @@ class GARClient {
|
|
|
1125
1129
|
);
|
|
1126
1130
|
}
|
|
1127
1131
|
|
|
1132
|
+
/**
|
|
1133
|
+
* Send an ActiveOwnership message if the parameters differ from the last sent values.
|
|
1134
|
+
* @param {Object} [options]
|
|
1135
|
+
* @param {number} [options.msgRef=0] - Message reference for correlating recoverable error responses.
|
|
1136
|
+
* @param {string} [options.ownershipAction='None'] - 'None' (check only), 'Acquire', or 'Release'.
|
|
1137
|
+
* @param {boolean} [options.skipOwnershipChecks=false] - Bypass ownership validation.
|
|
1138
|
+
* @param {number} [options.clientKeyId=0] - The g::Client key ID for ownership. 0 uses the connection key.
|
|
1139
|
+
*/
|
|
1140
|
+
updateActiveOwnership({ msgRef = 0, ownershipAction = 'None', skipOwnershipChecks = false, clientKeyId = 0 } = {}) {
|
|
1141
|
+
const newOwnership = { msg_ref: msgRef, ownership_action: ownershipAction, skip_ownership_checks: skipOwnershipChecks, client_key_id: clientKeyId };
|
|
1142
|
+
const cur = this._activeOwnership;
|
|
1143
|
+
if (newOwnership.msg_ref !== cur.msg_ref || newOwnership.ownership_action !== cur.ownership_action || newOwnership.skip_ownership_checks !== cur.skip_ownership_checks || newOwnership.client_key_id !== cur.client_key_id) {
|
|
1144
|
+
this._activeOwnership = newOwnership;
|
|
1145
|
+
this.sendMessage({ message_type: 'ActiveOwnership', value: newOwnership });
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1128
1149
|
/**
|
|
1129
1150
|
* Introduce a new key if not already known and return local key ID.
|
|
1130
1151
|
* @param {string} name - Key name
|
|
@@ -1135,25 +1156,15 @@ class GARClient {
|
|
|
1135
1156
|
if (!this.localKeyMap.has(name)) {
|
|
1136
1157
|
const keyId = this.localKeyCounter++;
|
|
1137
1158
|
this.localKeyMap.set(name, keyId);
|
|
1138
|
-
|
|
1159
|
+
const value = { key_id: keyId, name };
|
|
1139
1160
|
if (className) {
|
|
1140
1161
|
if (typeof className === 'string') {
|
|
1141
|
-
|
|
1162
|
+
value.class_list = className.split(/\s+/).filter(Boolean);
|
|
1142
1163
|
} else if (Array.isArray(className)) {
|
|
1143
|
-
|
|
1164
|
+
value.class_list = className;
|
|
1144
1165
|
}
|
|
1145
1166
|
}
|
|
1146
|
-
|
|
1147
|
-
message_type: 'KeyIntroduction',
|
|
1148
|
-
value: {
|
|
1149
|
-
key_id: keyId,
|
|
1150
|
-
name
|
|
1151
|
-
}
|
|
1152
|
-
};
|
|
1153
|
-
if (classList) {
|
|
1154
|
-
msg.value.class_list = classList;
|
|
1155
|
-
}
|
|
1156
|
-
this.sendMessage(msg);
|
|
1167
|
+
this.sendMessage({ message_type: 'KeyIntroduction', value });
|
|
1157
1168
|
}
|
|
1158
1169
|
return this.localKeyMap.get(name);
|
|
1159
1170
|
}
|