@interopio/browser 4.1.1 → 4.1.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.
- package/browser.d.ts +3202 -3161
- package/changelog.md +244 -242
- package/dist/browser.es.js +185 -58
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.umd.js +185 -58
- package/dist/browser.umd.js.map +1 -1
- package/dist/browser.umd.min.js +1 -1
- package/license.md +21 -21
- package/package.json +6 -6
- package/readme.md +9 -9
package/dist/browser.umd.js
CHANGED
|
@@ -2629,6 +2629,13 @@
|
|
|
2629
2629
|
appName: nonEmptyStringDecoder$2,
|
|
2630
2630
|
waitResponseTimeout: number$2()
|
|
2631
2631
|
});
|
|
2632
|
+
const handlerExclusionCriteriaApplicationNameDecoder = object$2({
|
|
2633
|
+
applicationName: nonEmptyStringDecoder$2
|
|
2634
|
+
});
|
|
2635
|
+
const handlerExclusionCriteriaInstanceIdDecoder = object$2({
|
|
2636
|
+
instanceId: nonEmptyStringDecoder$2
|
|
2637
|
+
});
|
|
2638
|
+
const handlerExclusionCriteriaDecoder = oneOf$1(handlerExclusionCriteriaApplicationNameDecoder, handlerExclusionCriteriaInstanceIdDecoder);
|
|
2632
2639
|
const handlerFilterDecoder = object$2({
|
|
2633
2640
|
title: optional$2(nonEmptyStringDecoder$2),
|
|
2634
2641
|
openResolver: optional$2(boolean$2()),
|
|
@@ -2636,7 +2643,8 @@
|
|
|
2636
2643
|
intent: optional$2(nonEmptyStringDecoder$2),
|
|
2637
2644
|
contextTypes: optional$2(array$2(nonEmptyStringDecoder$2)),
|
|
2638
2645
|
resultType: optional$2(nonEmptyStringDecoder$2),
|
|
2639
|
-
applicationNames: optional$2(array$2(nonEmptyStringDecoder$2))
|
|
2646
|
+
applicationNames: optional$2(array$2(nonEmptyStringDecoder$2)),
|
|
2647
|
+
excludeList: optional$2(array$2(handlerExclusionCriteriaDecoder))
|
|
2640
2648
|
});
|
|
2641
2649
|
const embeddedResolverConfigDecoder = object$2({
|
|
2642
2650
|
enabled: boolean$2(),
|
|
@@ -7736,7 +7744,7 @@
|
|
|
7736
7744
|
}
|
|
7737
7745
|
}
|
|
7738
7746
|
|
|
7739
|
-
var version$1 = "4.1.
|
|
7747
|
+
var version$1 = "4.1.3";
|
|
7740
7748
|
|
|
7741
7749
|
const setupGlobalSystem = (io, bridge) => {
|
|
7742
7750
|
return {
|
|
@@ -8023,7 +8031,10 @@
|
|
|
8023
8031
|
type: "define",
|
|
8024
8032
|
metrics: [rootStateMetric],
|
|
8025
8033
|
};
|
|
8026
|
-
session.
|
|
8034
|
+
session.sendFireAndForget(defineRootMetricsMsg)
|
|
8035
|
+
.catch((err) => {
|
|
8036
|
+
config.logger.warn(`Failed to send define for root state metric: ${JSON.stringify(err)}`);
|
|
8037
|
+
});
|
|
8027
8038
|
if (reconnect) {
|
|
8028
8039
|
replayRepo(repo);
|
|
8029
8040
|
}
|
|
@@ -8071,7 +8082,10 @@
|
|
|
8071
8082
|
type: "define",
|
|
8072
8083
|
metrics: [metric],
|
|
8073
8084
|
};
|
|
8074
|
-
session.
|
|
8085
|
+
session.sendFireAndForget(createMetricsMsg)
|
|
8086
|
+
.catch((err) => {
|
|
8087
|
+
config.logger.warn(`Failed to send define for system state metric of ${system.name}: ${JSON.stringify(err)}`);
|
|
8088
|
+
});
|
|
8075
8089
|
};
|
|
8076
8090
|
const updateSystem = async (system, state) => {
|
|
8077
8091
|
await joinPromise;
|
|
@@ -8086,7 +8100,10 @@
|
|
|
8086
8100
|
timestamp: Date.now(),
|
|
8087
8101
|
}],
|
|
8088
8102
|
};
|
|
8089
|
-
session.
|
|
8103
|
+
session.sendFireAndForget(shadowedUpdateMetric)
|
|
8104
|
+
.catch((err) => {
|
|
8105
|
+
config.logger.warn(`Failed to send update for system state metric of ${system.name}: ${JSON.stringify(err)}`);
|
|
8106
|
+
});
|
|
8090
8107
|
const stateObj = composeMsgForRootStateMetric(system);
|
|
8091
8108
|
const rootMetric = {
|
|
8092
8109
|
type: "publish",
|
|
@@ -8100,7 +8117,10 @@
|
|
|
8100
8117
|
timestamp: Date.now(),
|
|
8101
8118
|
}],
|
|
8102
8119
|
};
|
|
8103
|
-
session.
|
|
8120
|
+
session.sendFireAndForget(rootMetric)
|
|
8121
|
+
.catch((err) => {
|
|
8122
|
+
config.logger.warn(`Failed to send update for root state metric of ${system.name}: ${JSON.stringify(err)}`);
|
|
8123
|
+
});
|
|
8104
8124
|
};
|
|
8105
8125
|
const createMetric = async (metric) => {
|
|
8106
8126
|
const metricClone = cloneMetric(metric);
|
|
@@ -8110,7 +8130,10 @@
|
|
|
8110
8130
|
type: "define",
|
|
8111
8131
|
metrics: [m],
|
|
8112
8132
|
};
|
|
8113
|
-
session.
|
|
8133
|
+
session.sendFireAndForget(createMetricsMsg)
|
|
8134
|
+
.catch((err) => {
|
|
8135
|
+
config.logger.warn(`Failed to send define for metric ${metric.name}: ${JSON.stringify(err)}`);
|
|
8136
|
+
});
|
|
8114
8137
|
if (typeof metricClone.value !== "undefined") {
|
|
8115
8138
|
updateMetricCore(metricClone);
|
|
8116
8139
|
}
|
|
@@ -8131,7 +8154,10 @@
|
|
|
8131
8154
|
timestamp: Date.now(),
|
|
8132
8155
|
}],
|
|
8133
8156
|
};
|
|
8134
|
-
return session.sendFireAndForget(publishMetricsMsg)
|
|
8157
|
+
return session.sendFireAndForget(publishMetricsMsg)
|
|
8158
|
+
.catch((err) => {
|
|
8159
|
+
config.logger.warn(`Failed to publish metric ${metric.name}: ${JSON.stringify(err)}`);
|
|
8160
|
+
});
|
|
8135
8161
|
}
|
|
8136
8162
|
return Promise.resolve();
|
|
8137
8163
|
};
|
|
@@ -8998,8 +9024,9 @@
|
|
|
8998
9024
|
const pw = new PromiseWrapper();
|
|
8999
9025
|
this.logger.debug(`initiating ws to ${this.settings.ws}...`);
|
|
9000
9026
|
this.ws = new WebSocketConstructor(this.settings.ws ?? "");
|
|
9027
|
+
let wasOpen = false;
|
|
9001
9028
|
this.ws.onerror = (err) => {
|
|
9002
|
-
let reason
|
|
9029
|
+
let reason;
|
|
9003
9030
|
try {
|
|
9004
9031
|
reason = JSON.stringify(err);
|
|
9005
9032
|
}
|
|
@@ -9018,17 +9045,26 @@
|
|
|
9018
9045
|
}
|
|
9019
9046
|
this.logger.info(`ws error - reason: ${reason}`);
|
|
9020
9047
|
pw.reject("error");
|
|
9048
|
+
if (wasOpen) {
|
|
9049
|
+
wasOpen = false;
|
|
9050
|
+
this.notifyForSocketState("error");
|
|
9051
|
+
}
|
|
9021
9052
|
this.notifyStatusChanged(false, reason);
|
|
9022
9053
|
};
|
|
9023
9054
|
this.ws.onclose = (err) => {
|
|
9024
9055
|
this.logger.info(`ws closed - code: ${err?.code} reason: ${err?.reason}`);
|
|
9025
9056
|
pw.reject("closed");
|
|
9057
|
+
if (wasOpen) {
|
|
9058
|
+
wasOpen = false;
|
|
9059
|
+
this.notifyForSocketState("closed");
|
|
9060
|
+
}
|
|
9026
9061
|
this.notifyStatusChanged(false);
|
|
9027
9062
|
};
|
|
9028
9063
|
this.ws.onopen = () => {
|
|
9029
9064
|
this.startupTimer.mark("ws-opened");
|
|
9030
9065
|
this.logger.info(`ws opened ${this.settings.identity?.application}`);
|
|
9031
9066
|
pw.resolve();
|
|
9067
|
+
wasOpen = true;
|
|
9032
9068
|
this.notifyStatusChanged(true);
|
|
9033
9069
|
};
|
|
9034
9070
|
this.ws.onmessage = (message) => {
|
|
@@ -9816,17 +9852,31 @@
|
|
|
9816
9852
|
callbacks.execute("onJoined", wasReconnect);
|
|
9817
9853
|
}
|
|
9818
9854
|
function handleConnectionDisconnected() {
|
|
9819
|
-
_connectionOn = false;
|
|
9820
9855
|
logger.debug("connection is down");
|
|
9856
|
+
_connectionOn = false;
|
|
9821
9857
|
isJoined = false;
|
|
9822
9858
|
tryReconnecting = true;
|
|
9859
|
+
Object.keys(requestsMap).forEach(requestId => {
|
|
9860
|
+
const request = requestsMap[requestId];
|
|
9861
|
+
if (request) {
|
|
9862
|
+
logger.trace(`failing pending request ${requestId} due to connection lost`);
|
|
9863
|
+
request.error({
|
|
9864
|
+
err: "Connection lost - gateway connection was disconnected"
|
|
9865
|
+
});
|
|
9866
|
+
}
|
|
9867
|
+
});
|
|
9823
9868
|
callbacks.execute("onLeft", { disconnected: true });
|
|
9824
9869
|
}
|
|
9825
|
-
function handleConnectionLoggedIn() {
|
|
9870
|
+
async function handleConnectionLoggedIn() {
|
|
9826
9871
|
_connectionOn = true;
|
|
9827
9872
|
if (tryReconnecting) {
|
|
9828
9873
|
logger.debug("connection is now up - trying to reconnect...");
|
|
9829
|
-
|
|
9874
|
+
try {
|
|
9875
|
+
await join(_latestOptions);
|
|
9876
|
+
}
|
|
9877
|
+
catch {
|
|
9878
|
+
logger.trace(`failed to reconnect`);
|
|
9879
|
+
}
|
|
9830
9880
|
}
|
|
9831
9881
|
}
|
|
9832
9882
|
function onJoined(callback) {
|
|
@@ -9919,7 +9969,7 @@
|
|
|
9919
9969
|
connection
|
|
9920
9970
|
.send(msg, options)
|
|
9921
9971
|
.catch((err) => {
|
|
9922
|
-
requestsMap[requestId]
|
|
9972
|
+
requestsMap[requestId]?.error({ err });
|
|
9923
9973
|
});
|
|
9924
9974
|
});
|
|
9925
9975
|
}
|
|
@@ -9998,6 +10048,7 @@
|
|
|
9998
10048
|
initialLogin = true;
|
|
9999
10049
|
initialLoginAttempts = 3;
|
|
10000
10050
|
loginConfig;
|
|
10051
|
+
loginRetryInProgress = false;
|
|
10001
10052
|
constructor(settings, logger) {
|
|
10002
10053
|
this.settings = settings;
|
|
10003
10054
|
this.logger = logger;
|
|
@@ -10111,6 +10162,7 @@
|
|
|
10111
10162
|
return this.registry.add("disconnected", callback);
|
|
10112
10163
|
}
|
|
10113
10164
|
async login(authRequest, reconnect) {
|
|
10165
|
+
this.logger.debug(`Login initiated - reconnect: ${reconnect}, transport: ${this.transport.name()}`);
|
|
10114
10166
|
if (!this._defaultAuth) {
|
|
10115
10167
|
this._defaultAuth = authRequest;
|
|
10116
10168
|
}
|
|
@@ -10119,19 +10171,18 @@
|
|
|
10119
10171
|
const newAuth = this.transportSwap();
|
|
10120
10172
|
authRequest = newAuth ?? authRequest;
|
|
10121
10173
|
}
|
|
10122
|
-
this.logger.trace(`Starting login for transport: ${this.transport.name()} and auth ${JSON.stringify(authRequest)}`);
|
|
10123
10174
|
try {
|
|
10124
10175
|
await this.transport.open();
|
|
10125
|
-
this.logger.
|
|
10176
|
+
this.logger.debug(`Transport: ${this.transport.name()} opened, logging in`);
|
|
10126
10177
|
timer("connection").mark("transport-opened");
|
|
10127
10178
|
const identity = await this.loginCore(authRequest, reconnect);
|
|
10128
|
-
this.logger.
|
|
10179
|
+
this.logger.debug(`Logged in with identity: ${JSON.stringify(identity)}`);
|
|
10129
10180
|
timer("connection").mark("protocol-logged-in");
|
|
10130
10181
|
return identity;
|
|
10131
10182
|
}
|
|
10132
10183
|
catch (error) {
|
|
10133
10184
|
if (this._switchInProgress) {
|
|
10134
|
-
this.logger.
|
|
10185
|
+
this.logger.debug("An error while logging in after a transport swap, preparing a default swap.");
|
|
10135
10186
|
this.prepareDefaultSwap();
|
|
10136
10187
|
}
|
|
10137
10188
|
throw new Error(error);
|
|
@@ -10174,6 +10225,7 @@
|
|
|
10174
10225
|
setLoggedIn(value) {
|
|
10175
10226
|
this._isLoggedIn = value;
|
|
10176
10227
|
if (this._isLoggedIn) {
|
|
10228
|
+
this.initialLogin = false;
|
|
10177
10229
|
this.registry.execute("onLoggedIn");
|
|
10178
10230
|
}
|
|
10179
10231
|
}
|
|
@@ -10200,8 +10252,10 @@
|
|
|
10200
10252
|
}
|
|
10201
10253
|
handleConnectionChanged(connected) {
|
|
10202
10254
|
if (this._connected === connected) {
|
|
10255
|
+
this.logger.trace("connection state unchanged, skipping");
|
|
10203
10256
|
return;
|
|
10204
10257
|
}
|
|
10258
|
+
this.logger.info(`connection state changed to ${connected ? "connected" : "disconnected"}`);
|
|
10205
10259
|
this._connected = connected;
|
|
10206
10260
|
if (connected) {
|
|
10207
10261
|
if (this.settings?.replaySpecs?.length) {
|
|
@@ -10211,28 +10265,44 @@
|
|
|
10211
10265
|
this.registry.execute("connected");
|
|
10212
10266
|
}
|
|
10213
10267
|
else {
|
|
10214
|
-
this.
|
|
10268
|
+
this.setLoggedIn(false);
|
|
10269
|
+
if (this.shouldTryLogin) {
|
|
10270
|
+
this.attemptLoginWithRetry();
|
|
10271
|
+
}
|
|
10215
10272
|
this.registry.execute("disconnected");
|
|
10216
10273
|
}
|
|
10217
10274
|
}
|
|
10218
|
-
|
|
10219
|
-
this.
|
|
10220
|
-
|
|
10221
|
-
|
|
10275
|
+
async attemptLoginWithRetry() {
|
|
10276
|
+
if (!this.loginConfig) {
|
|
10277
|
+
throw new Error("no login info");
|
|
10278
|
+
}
|
|
10279
|
+
if (this.loginRetryInProgress) {
|
|
10280
|
+
this.logger.debug("login attempt already in progress, ignoring request...");
|
|
10281
|
+
return;
|
|
10282
|
+
}
|
|
10283
|
+
if (this._isLoggedIn) {
|
|
10284
|
+
this.logger.debug("already logged in, ignoring request...");
|
|
10285
|
+
return;
|
|
10286
|
+
}
|
|
10287
|
+
if (this.initialLogin) {
|
|
10288
|
+
this.logger.debug(`initial login attempt failed, ${this.initialLoginAttempts} attempts remaining...`);
|
|
10222
10289
|
if (this.initialLoginAttempts <= 0) {
|
|
10290
|
+
this.logger.info("maximum initial login attempts reached, will not try to login again");
|
|
10223
10291
|
return;
|
|
10224
10292
|
}
|
|
10225
10293
|
this.initialLoginAttempts--;
|
|
10226
10294
|
}
|
|
10227
|
-
|
|
10228
|
-
|
|
10229
|
-
|
|
10230
|
-
|
|
10231
|
-
|
|
10232
|
-
|
|
10233
|
-
|
|
10234
|
-
|
|
10235
|
-
|
|
10295
|
+
try {
|
|
10296
|
+
this.logger.debug(`will try a new login... ${this.loginRetryInProgress}`);
|
|
10297
|
+
this.loginRetryInProgress = true;
|
|
10298
|
+
await this.login(this.loginConfig, true);
|
|
10299
|
+
}
|
|
10300
|
+
catch (e) {
|
|
10301
|
+
this.logger.error(`error trying to login: ${e?.message}`, e);
|
|
10302
|
+
setTimeout(this.attemptLoginWithRetry.bind(this), this.settings.reconnectInterval ?? 1000);
|
|
10303
|
+
}
|
|
10304
|
+
finally {
|
|
10305
|
+
this.loginRetryInProgress = false;
|
|
10236
10306
|
}
|
|
10237
10307
|
}
|
|
10238
10308
|
handleTransportMessage(msg) {
|
|
@@ -10359,7 +10429,6 @@
|
|
|
10359
10429
|
return message;
|
|
10360
10430
|
}
|
|
10361
10431
|
async loginCore(config, reconnect) {
|
|
10362
|
-
this.logger.info("logging in...");
|
|
10363
10432
|
this.loginConfig = config;
|
|
10364
10433
|
if (!this.loginConfig) {
|
|
10365
10434
|
this.loginConfig = { username: "", password: "" };
|
|
@@ -10374,11 +10443,13 @@
|
|
|
10374
10443
|
if (config.sessionId) {
|
|
10375
10444
|
helloMsg.request_id = config.sessionId;
|
|
10376
10445
|
}
|
|
10377
|
-
|
|
10378
|
-
"
|
|
10379
|
-
|
|
10380
|
-
|
|
10381
|
-
|
|
10446
|
+
if (!this.globalDomain) {
|
|
10447
|
+
this.globalDomain = domainSession("global", this, this.logger.subLogger("global-domain"), [
|
|
10448
|
+
"welcome",
|
|
10449
|
+
"token",
|
|
10450
|
+
"authentication-request"
|
|
10451
|
+
]);
|
|
10452
|
+
}
|
|
10382
10453
|
const sendOptions = { skipPeerId: true };
|
|
10383
10454
|
if (this.initialLogin) {
|
|
10384
10455
|
sendOptions.retryInterval = this.settings.reconnectInterval;
|
|
@@ -10386,7 +10457,6 @@
|
|
|
10386
10457
|
}
|
|
10387
10458
|
try {
|
|
10388
10459
|
const welcomeMsg = await this.tryAuthenticate(this.globalDomain, helloMsg, sendOptions, config);
|
|
10389
|
-
this.initialLogin = false;
|
|
10390
10460
|
this.logger.info("login successful with peerId " + welcomeMsg.peer_id);
|
|
10391
10461
|
this.peerId = welcomeMsg.peer_id;
|
|
10392
10462
|
this.resolvedIdentity = welcomeMsg.resolved_identity;
|
|
@@ -10489,7 +10559,7 @@
|
|
|
10489
10559
|
clearTimeout(this.pingTimer);
|
|
10490
10560
|
}
|
|
10491
10561
|
const promises = this.sessions.map((session) => {
|
|
10492
|
-
session.leave();
|
|
10562
|
+
return session.leave();
|
|
10493
10563
|
});
|
|
10494
10564
|
await Promise.all(promises);
|
|
10495
10565
|
}
|
|
@@ -10714,7 +10784,7 @@
|
|
|
10714
10784
|
}
|
|
10715
10785
|
};
|
|
10716
10786
|
|
|
10717
|
-
var version = "6.7.
|
|
10787
|
+
var version = "6.7.1";
|
|
10718
10788
|
|
|
10719
10789
|
function prepareConfig (configuration, ext, glue42gd) {
|
|
10720
10790
|
let nodeStartingContext;
|
|
@@ -12841,6 +12911,8 @@
|
|
|
12841
12911
|
}
|
|
12842
12912
|
|
|
12843
12913
|
class GW3Bridge {
|
|
12914
|
+
ERROR_URI_FAILURE = "global.errors.failure";
|
|
12915
|
+
ERROR_URI_INVALID_CONTEXT = "global.errors.invalid_context";
|
|
12844
12916
|
_logger;
|
|
12845
12917
|
_connection;
|
|
12846
12918
|
_trackAllContexts;
|
|
@@ -12885,7 +12957,11 @@
|
|
|
12885
12957
|
if (!this._reAnnounceKnownContexts) {
|
|
12886
12958
|
return this._connection.setLibReAnnounced({ name: "contexts" });
|
|
12887
12959
|
}
|
|
12888
|
-
this.reInitiateState()
|
|
12960
|
+
this.reInitiateState()
|
|
12961
|
+
.then(() => this._connection.setLibReAnnounced({ name: "contexts" }))
|
|
12962
|
+
.catch((err) => {
|
|
12963
|
+
this._logger.warn(`Error while re-announcing contexts: ${JSON.stringify(err)}`);
|
|
12964
|
+
});
|
|
12889
12965
|
});
|
|
12890
12966
|
this.subscribeToContextCreatedMessages();
|
|
12891
12967
|
this.subscribeToContextUpdatedMessages();
|
|
@@ -12963,7 +13039,8 @@
|
|
|
12963
13039
|
}
|
|
12964
13040
|
const contextData = this._contextNameToData[name];
|
|
12965
13041
|
if (!contextData || !contextData.isAnnounced) {
|
|
12966
|
-
|
|
13042
|
+
await this.createContext(name, delta);
|
|
13043
|
+
return;
|
|
12967
13044
|
}
|
|
12968
13045
|
let currentContext = contextData.context;
|
|
12969
13046
|
if (!contextData.hasCallbacks()) {
|
|
@@ -13080,16 +13157,26 @@
|
|
|
13080
13157
|
return Promise.resolve({});
|
|
13081
13158
|
}
|
|
13082
13159
|
if (contextData && (!contextData.hasCallbacks() || !contextData.hasReceivedSnapshot)) {
|
|
13083
|
-
return new Promise((resolve) => {
|
|
13160
|
+
return new Promise((resolve, reject) => {
|
|
13084
13161
|
this.subscribe(name, (data, _d, _r, un) => {
|
|
13085
13162
|
this.unsubscribe(un);
|
|
13086
13163
|
resolve(data);
|
|
13164
|
+
}).catch((e) => {
|
|
13165
|
+
if (this.isInvalidContextError(e)) {
|
|
13166
|
+
resolve({});
|
|
13167
|
+
return;
|
|
13168
|
+
}
|
|
13169
|
+
reject(e);
|
|
13087
13170
|
});
|
|
13088
13171
|
});
|
|
13089
13172
|
}
|
|
13090
13173
|
const context = contextData?.context ?? {};
|
|
13091
13174
|
return Promise.resolve(deepClone(context));
|
|
13092
13175
|
}
|
|
13176
|
+
isInvalidContextError(e) {
|
|
13177
|
+
return e.reason_uri === this.ERROR_URI_INVALID_CONTEXT
|
|
13178
|
+
|| (e.reason_uri === this.ERROR_URI_FAILURE && e.reason?.startsWith("Unable to find context with id"));
|
|
13179
|
+
}
|
|
13093
13180
|
async subscribe(name, callback, subscriptionKey) {
|
|
13094
13181
|
if (name in this._creationPromises) {
|
|
13095
13182
|
await this._creationPromises[name];
|
|
@@ -13173,7 +13260,7 @@
|
|
|
13173
13260
|
type: GW_MESSAGE_DESTROY_CONTEXT,
|
|
13174
13261
|
domain: "global",
|
|
13175
13262
|
context_id: contextData.contextId,
|
|
13176
|
-
}).then((
|
|
13263
|
+
}).then(() => undefined);
|
|
13177
13264
|
}
|
|
13178
13265
|
handleUpdated(contextData, delta, extraData) {
|
|
13179
13266
|
const oldContext = contextData.context;
|
|
@@ -13226,7 +13313,7 @@
|
|
|
13226
13313
|
contextData.contextId = contextCreatedMsg.context_id;
|
|
13227
13314
|
contextData.activityId = contextCreatedMsg.activity_id;
|
|
13228
13315
|
if (!contextData.sentExplicitSubscription) {
|
|
13229
|
-
this.sendSubscribe(contextData);
|
|
13316
|
+
this.sendSubscribe(contextData).catch(() => { });
|
|
13230
13317
|
}
|
|
13231
13318
|
}
|
|
13232
13319
|
}
|
|
@@ -13378,16 +13465,25 @@
|
|
|
13378
13465
|
type: GW_MESSAGE_SUBSCRIBE_CONTEXT,
|
|
13379
13466
|
domain: "global",
|
|
13380
13467
|
context_id: contextData.contextId,
|
|
13381
|
-
})
|
|
13468
|
+
})
|
|
13469
|
+
.then(() => undefined)
|
|
13470
|
+
.catch(() => {
|
|
13471
|
+
contextData.sentExplicitSubscription = false;
|
|
13472
|
+
});
|
|
13382
13473
|
}
|
|
13383
13474
|
sendUnsubscribe(contextData) {
|
|
13475
|
+
const prev = contextData.sentExplicitSubscription;
|
|
13384
13476
|
contextData.sentExplicitSubscription = false;
|
|
13385
13477
|
return this._gw3Session
|
|
13386
13478
|
.send({
|
|
13387
13479
|
type: GW_MESSAGE_UNSUBSCRIBE_CONTEXT,
|
|
13388
13480
|
domain: "global",
|
|
13389
13481
|
context_id: contextData.contextId,
|
|
13390
|
-
})
|
|
13482
|
+
})
|
|
13483
|
+
.then(() => undefined)
|
|
13484
|
+
.catch(() => {
|
|
13485
|
+
contextData.sentExplicitSubscription = prev;
|
|
13486
|
+
});
|
|
13391
13487
|
}
|
|
13392
13488
|
calculateContextDeltaV1(from, to) {
|
|
13393
13489
|
const delta = { added: {}, updated: {}, removed: [], reset: undefined };
|
|
@@ -15630,13 +15726,15 @@
|
|
|
15630
15726
|
session;
|
|
15631
15727
|
repository;
|
|
15632
15728
|
serverRepository;
|
|
15729
|
+
logger;
|
|
15633
15730
|
ERR_URI_SUBSCRIPTION_FAILED = "com.tick42.agm.errors.subscription.failure";
|
|
15634
15731
|
callbacks = CallbackRegistryFactory();
|
|
15635
15732
|
nextStreamId = 0;
|
|
15636
|
-
constructor(session, repository, serverRepository) {
|
|
15733
|
+
constructor(session, repository, serverRepository, logger) {
|
|
15637
15734
|
this.session = session;
|
|
15638
15735
|
this.repository = repository;
|
|
15639
15736
|
this.serverRepository = serverRepository;
|
|
15737
|
+
this.logger = logger;
|
|
15640
15738
|
session.on("add-interest", (msg) => {
|
|
15641
15739
|
this.handleAddInterest(msg);
|
|
15642
15740
|
});
|
|
@@ -15669,6 +15767,8 @@
|
|
|
15669
15767
|
type: "accepted",
|
|
15670
15768
|
subscription_id: key,
|
|
15671
15769
|
stream_id: streamId,
|
|
15770
|
+
}).catch((err) => {
|
|
15771
|
+
this.logger.warn(`Failed to send accepted message for subscription ${key}: ${JSON.stringify(err)}`);
|
|
15672
15772
|
});
|
|
15673
15773
|
this.callbacks.execute(SUBSCRIPTION_ADDED, subscription, streamingMethod);
|
|
15674
15774
|
}
|
|
@@ -15706,7 +15806,10 @@
|
|
|
15706
15806
|
stream_id: streamId,
|
|
15707
15807
|
data,
|
|
15708
15808
|
};
|
|
15709
|
-
this.session.sendFireAndForget(publishMessage)
|
|
15809
|
+
this.session.sendFireAndForget(publishMessage)
|
|
15810
|
+
.catch((err) => {
|
|
15811
|
+
this.logger.warn(`Failed to send publish message for stream ${streamId}: ${JSON.stringify(err)}`);
|
|
15812
|
+
});
|
|
15710
15813
|
});
|
|
15711
15814
|
}
|
|
15712
15815
|
pushDataToSingle(method, subscription, data) {
|
|
@@ -15718,7 +15821,10 @@
|
|
|
15718
15821
|
subscription_id: subscription.id,
|
|
15719
15822
|
data,
|
|
15720
15823
|
};
|
|
15721
|
-
this.session.sendFireAndForget(postMessage)
|
|
15824
|
+
this.session.sendFireAndForget(postMessage)
|
|
15825
|
+
.catch((err) => {
|
|
15826
|
+
this.logger.warn(`Failed to send post message for subscription ${subscription.id}: ${JSON.stringify(err)}`);
|
|
15827
|
+
});
|
|
15722
15828
|
}
|
|
15723
15829
|
closeSingleSubscription(streamingMethod, subscription) {
|
|
15724
15830
|
if (streamingMethod.protocolState.subscriptionsMap) {
|
|
@@ -15729,7 +15835,10 @@
|
|
|
15729
15835
|
subscription_id: subscription.id,
|
|
15730
15836
|
reason: "Server dropping a single subscription",
|
|
15731
15837
|
};
|
|
15732
|
-
this.session.sendFireAndForget(dropSubscriptionMessage)
|
|
15838
|
+
this.session.sendFireAndForget(dropSubscriptionMessage)
|
|
15839
|
+
.catch((err) => {
|
|
15840
|
+
this.logger.warn(`Failed to send drop-subscription message for subscription ${subscription.id}: ${JSON.stringify(err)}`);
|
|
15841
|
+
});
|
|
15733
15842
|
subscription.instance;
|
|
15734
15843
|
this.callbacks.execute(SUBSCRIPTION_REMOVED, subscription, streamingMethod);
|
|
15735
15844
|
}
|
|
@@ -15757,7 +15866,10 @@
|
|
|
15757
15866
|
subscription_id: subscription.id,
|
|
15758
15867
|
reason: "Server dropping all subscriptions on stream_id: " + subscription.streamId,
|
|
15759
15868
|
};
|
|
15760
|
-
this.session.sendFireAndForget(drop)
|
|
15869
|
+
this.session.sendFireAndForget(drop)
|
|
15870
|
+
.catch((err) => {
|
|
15871
|
+
this.logger.warn(`Failed to send drop-subscription message for subscription ${subscription.id}: ${JSON.stringify(err)}`);
|
|
15872
|
+
});
|
|
15761
15873
|
});
|
|
15762
15874
|
}
|
|
15763
15875
|
getSubscriptionList(streamingMethod, branchKey) {
|
|
@@ -15866,7 +15978,10 @@
|
|
|
15866
15978
|
reason,
|
|
15867
15979
|
request_id: subscriptionId,
|
|
15868
15980
|
};
|
|
15869
|
-
this.session.sendFireAndForget(errorMessage)
|
|
15981
|
+
this.session.sendFireAndForget(errorMessage)
|
|
15982
|
+
.catch((err) => {
|
|
15983
|
+
this.logger.warn(`Failed to send subscription failed message for subscription ${subscriptionId}: ${JSON.stringify(err)}`);
|
|
15984
|
+
});
|
|
15870
15985
|
}
|
|
15871
15986
|
getStreamId(streamingMethod, branchKey) {
|
|
15872
15987
|
if (typeof branchKey !== "string") {
|
|
@@ -15899,7 +16014,7 @@
|
|
|
15899
16014
|
this.clientRepository = clientRepository;
|
|
15900
16015
|
this.serverRepository = serverRepository;
|
|
15901
16016
|
this.logger = logger;
|
|
15902
|
-
this.streaming = new ServerStreaming(session, clientRepository, serverRepository);
|
|
16017
|
+
this.streaming = new ServerStreaming(session, clientRepository, serverRepository, logger.subLogger("streaming"));
|
|
15903
16018
|
this.session.on("invoke", (msg) => this.handleInvokeMessage(msg));
|
|
15904
16019
|
}
|
|
15905
16020
|
createStream(repoMethod) {
|
|
@@ -15958,7 +16073,10 @@
|
|
|
15958
16073
|
request_id: undefined,
|
|
15959
16074
|
};
|
|
15960
16075
|
}
|
|
15961
|
-
this.session.sendFireAndForget(msg)
|
|
16076
|
+
this.session.sendFireAndForget(msg)
|
|
16077
|
+
.catch((error => {
|
|
16078
|
+
this.logger.warn(`Failed to send method invocation result for method ${method.definition.name} invocation ${invocationId} - ${JSON.stringify(error)}`);
|
|
16079
|
+
}));
|
|
15962
16080
|
}
|
|
15963
16081
|
async unregister(method) {
|
|
15964
16082
|
const msg = {
|
|
@@ -16418,6 +16536,8 @@
|
|
|
16418
16536
|
subscription_id: server.subscriptionId,
|
|
16419
16537
|
reason_uri: "",
|
|
16420
16538
|
reason: ON_CLOSE_MSG_CLIENT_INIT,
|
|
16539
|
+
}).catch((err) => {
|
|
16540
|
+
this.logger.warn(`Error sending unsubscribe for subscription id ${server.subscriptionId}: ${JSON.stringify(err)}`);
|
|
16421
16541
|
});
|
|
16422
16542
|
delete this.subscriptionIdToLocalKeyMap[server.subscriptionId];
|
|
16423
16543
|
});
|
|
@@ -16757,7 +16877,10 @@
|
|
|
16757
16877
|
routing_key: routingKey,
|
|
16758
16878
|
target_identity: target
|
|
16759
16879
|
});
|
|
16760
|
-
this.session.send(args)
|
|
16880
|
+
this.session.send(args)
|
|
16881
|
+
.catch((err) => {
|
|
16882
|
+
this.logger.error(`Failed to publish message to topic ${topic} with routing key ${routingKey} for ${JSON.stringify(target)}: ${JSON.stringify(err)}`);
|
|
16883
|
+
});
|
|
16761
16884
|
};
|
|
16762
16885
|
subscribe = (topic, callback, options) => {
|
|
16763
16886
|
return new Promise((resolve, reject) => {
|
|
@@ -16775,8 +16898,12 @@
|
|
|
16775
16898
|
this.subscriptions.push({ subscription_id, topic, callback, source: target });
|
|
16776
16899
|
resolve({
|
|
16777
16900
|
unsubscribe: () => {
|
|
16778
|
-
this.session.send({ type: "unsubscribe", subscription_id, peer_id: this.peerId })
|
|
16779
|
-
|
|
16901
|
+
this.session.send({ type: "unsubscribe", subscription_id, peer_id: this.peerId })
|
|
16902
|
+
.then(() => {
|
|
16903
|
+
this.subscriptions = this.subscriptions.filter((s) => s.subscription_id !== subscription_id);
|
|
16904
|
+
}).catch((err) => {
|
|
16905
|
+
this.logger.warn(`Failed to send unsubscribe request for ${subscription_id}: ${JSON.stringify(err)}`);
|
|
16906
|
+
});
|
|
16780
16907
|
return Promise.resolve();
|
|
16781
16908
|
}
|
|
16782
16909
|
});
|