@nsshunt/stsfhirclient 1.1.15 → 1.1.16
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/stsfhirclient.mjs +15 -892
- package/dist/stsfhirclient.mjs.map +1 -1
- package/dist/stsfhirclient.umd.js +17 -889
- package/dist/stsfhirclient.umd.js.map +1 -1
- package/package.json +5 -5
package/dist/stsfhirclient.mjs
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
2
|
import { Sleep, STSAxiosConfig } from "@nsshunt/stsutils";
|
|
3
3
|
import { Emitter } from "@socket.io/component-emitter";
|
|
4
|
-
import { Server } from "socket.io";
|
|
5
|
-
import { Redis } from "ioredis";
|
|
6
|
-
import require$$0 from "node:cluster";
|
|
7
|
-
import require$$1 from "socket.io-adapter";
|
|
8
|
-
import { createAdapter } from "@socket.io/redis-streams-adapter";
|
|
9
4
|
const isNode$1 = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
|
|
10
5
|
function getDefaultExportFromCjs(x) {
|
|
11
6
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
@@ -1117,16 +1112,16 @@ function requireAnsiStyles() {
|
|
|
1117
1112
|
})(ansiStyles);
|
|
1118
1113
|
return ansiStyles.exports;
|
|
1119
1114
|
}
|
|
1120
|
-
var browser
|
|
1121
|
-
var hasRequiredBrowser
|
|
1122
|
-
function requireBrowser
|
|
1123
|
-
if (hasRequiredBrowser
|
|
1124
|
-
hasRequiredBrowser
|
|
1125
|
-
browser
|
|
1115
|
+
var browser;
|
|
1116
|
+
var hasRequiredBrowser;
|
|
1117
|
+
function requireBrowser() {
|
|
1118
|
+
if (hasRequiredBrowser) return browser;
|
|
1119
|
+
hasRequiredBrowser = 1;
|
|
1120
|
+
browser = {
|
|
1126
1121
|
stdout: false,
|
|
1127
1122
|
stderr: false
|
|
1128
1123
|
};
|
|
1129
|
-
return browser
|
|
1124
|
+
return browser;
|
|
1130
1125
|
}
|
|
1131
1126
|
var util$1;
|
|
1132
1127
|
var hasRequiredUtil$1;
|
|
@@ -1287,7 +1282,7 @@ function requireSource() {
|
|
|
1287
1282
|
if (hasRequiredSource) return source;
|
|
1288
1283
|
hasRequiredSource = 1;
|
|
1289
1284
|
const ansiStyles2 = requireAnsiStyles();
|
|
1290
|
-
const { stdout: stdoutColor, stderr: stderrColor } = requireBrowser
|
|
1285
|
+
const { stdout: stdoutColor, stderr: stderrColor } = requireBrowser();
|
|
1291
1286
|
const {
|
|
1292
1287
|
stringReplaceAll,
|
|
1293
1288
|
stringEncaseCRLFWithFirstIndex
|
|
@@ -4351,13 +4346,13 @@ function Backoff(opts) {
|
|
|
4351
4346
|
this.attempts = 0;
|
|
4352
4347
|
}
|
|
4353
4348
|
Backoff.prototype.duration = function() {
|
|
4354
|
-
var
|
|
4349
|
+
var ms = this.ms * Math.pow(this.factor, this.attempts++);
|
|
4355
4350
|
if (this.jitter) {
|
|
4356
4351
|
var rand = Math.random();
|
|
4357
|
-
var deviation = Math.floor(rand * this.jitter *
|
|
4358
|
-
|
|
4352
|
+
var deviation = Math.floor(rand * this.jitter * ms);
|
|
4353
|
+
ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;
|
|
4359
4354
|
}
|
|
4360
|
-
return Math.min(
|
|
4355
|
+
return Math.min(ms, this.max) | 0;
|
|
4361
4356
|
};
|
|
4362
4357
|
Backoff.prototype.reset = function() {
|
|
4363
4358
|
this.attempts = 0;
|
|
@@ -4752,7 +4747,6 @@ Object.assign(lookup, {
|
|
|
4752
4747
|
io: lookup,
|
|
4753
4748
|
connect: lookup
|
|
4754
4749
|
});
|
|
4755
|
-
const isNode = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
|
|
4756
4750
|
var tinyEmitter = { exports: {} };
|
|
4757
4751
|
var hasRequiredTinyEmitter;
|
|
4758
4752
|
function requireTinyEmitter() {
|
|
@@ -4807,6 +4801,7 @@ function requireTinyEmitter() {
|
|
|
4807
4801
|
return tinyEmitter.exports;
|
|
4808
4802
|
}
|
|
4809
4803
|
var tinyEmitterExports = requireTinyEmitter();
|
|
4804
|
+
const isNode = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
|
|
4810
4805
|
class SocketIoClient extends tinyEmitterExports.TinyEmitter {
|
|
4811
4806
|
#agentManager;
|
|
4812
4807
|
#logger;
|
|
@@ -5004,878 +4999,6 @@ class SocketIoClient extends tinyEmitterExports.TinyEmitter {
|
|
|
5004
4999
|
});
|
|
5005
5000
|
}
|
|
5006
5001
|
}
|
|
5007
|
-
var dist = {};
|
|
5008
|
-
var browser = { exports: {} };
|
|
5009
|
-
var ms;
|
|
5010
|
-
var hasRequiredMs;
|
|
5011
|
-
function requireMs() {
|
|
5012
|
-
if (hasRequiredMs) return ms;
|
|
5013
|
-
hasRequiredMs = 1;
|
|
5014
|
-
var s = 1e3;
|
|
5015
|
-
var m = s * 60;
|
|
5016
|
-
var h = m * 60;
|
|
5017
|
-
var d = h * 24;
|
|
5018
|
-
var w = d * 7;
|
|
5019
|
-
var y = d * 365.25;
|
|
5020
|
-
ms = function(val, options) {
|
|
5021
|
-
options = options || {};
|
|
5022
|
-
var type2 = typeof val;
|
|
5023
|
-
if (type2 === "string" && val.length > 0) {
|
|
5024
|
-
return parse2(val);
|
|
5025
|
-
} else if (type2 === "number" && isFinite(val)) {
|
|
5026
|
-
return options.long ? fmtLong(val) : fmtShort(val);
|
|
5027
|
-
}
|
|
5028
|
-
throw new Error(
|
|
5029
|
-
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
|
5030
|
-
);
|
|
5031
|
-
};
|
|
5032
|
-
function parse2(str) {
|
|
5033
|
-
str = String(str);
|
|
5034
|
-
if (str.length > 100) {
|
|
5035
|
-
return;
|
|
5036
|
-
}
|
|
5037
|
-
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
|
5038
|
-
str
|
|
5039
|
-
);
|
|
5040
|
-
if (!match) {
|
|
5041
|
-
return;
|
|
5042
|
-
}
|
|
5043
|
-
var n = parseFloat(match[1]);
|
|
5044
|
-
var type2 = (match[2] || "ms").toLowerCase();
|
|
5045
|
-
switch (type2) {
|
|
5046
|
-
case "years":
|
|
5047
|
-
case "year":
|
|
5048
|
-
case "yrs":
|
|
5049
|
-
case "yr":
|
|
5050
|
-
case "y":
|
|
5051
|
-
return n * y;
|
|
5052
|
-
case "weeks":
|
|
5053
|
-
case "week":
|
|
5054
|
-
case "w":
|
|
5055
|
-
return n * w;
|
|
5056
|
-
case "days":
|
|
5057
|
-
case "day":
|
|
5058
|
-
case "d":
|
|
5059
|
-
return n * d;
|
|
5060
|
-
case "hours":
|
|
5061
|
-
case "hour":
|
|
5062
|
-
case "hrs":
|
|
5063
|
-
case "hr":
|
|
5064
|
-
case "h":
|
|
5065
|
-
return n * h;
|
|
5066
|
-
case "minutes":
|
|
5067
|
-
case "minute":
|
|
5068
|
-
case "mins":
|
|
5069
|
-
case "min":
|
|
5070
|
-
case "m":
|
|
5071
|
-
return n * m;
|
|
5072
|
-
case "seconds":
|
|
5073
|
-
case "second":
|
|
5074
|
-
case "secs":
|
|
5075
|
-
case "sec":
|
|
5076
|
-
case "s":
|
|
5077
|
-
return n * s;
|
|
5078
|
-
case "milliseconds":
|
|
5079
|
-
case "millisecond":
|
|
5080
|
-
case "msecs":
|
|
5081
|
-
case "msec":
|
|
5082
|
-
case "ms":
|
|
5083
|
-
return n;
|
|
5084
|
-
default:
|
|
5085
|
-
return void 0;
|
|
5086
|
-
}
|
|
5087
|
-
}
|
|
5088
|
-
function fmtShort(ms2) {
|
|
5089
|
-
var msAbs = Math.abs(ms2);
|
|
5090
|
-
if (msAbs >= d) {
|
|
5091
|
-
return Math.round(ms2 / d) + "d";
|
|
5092
|
-
}
|
|
5093
|
-
if (msAbs >= h) {
|
|
5094
|
-
return Math.round(ms2 / h) + "h";
|
|
5095
|
-
}
|
|
5096
|
-
if (msAbs >= m) {
|
|
5097
|
-
return Math.round(ms2 / m) + "m";
|
|
5098
|
-
}
|
|
5099
|
-
if (msAbs >= s) {
|
|
5100
|
-
return Math.round(ms2 / s) + "s";
|
|
5101
|
-
}
|
|
5102
|
-
return ms2 + "ms";
|
|
5103
|
-
}
|
|
5104
|
-
function fmtLong(ms2) {
|
|
5105
|
-
var msAbs = Math.abs(ms2);
|
|
5106
|
-
if (msAbs >= d) {
|
|
5107
|
-
return plural(ms2, msAbs, d, "day");
|
|
5108
|
-
}
|
|
5109
|
-
if (msAbs >= h) {
|
|
5110
|
-
return plural(ms2, msAbs, h, "hour");
|
|
5111
|
-
}
|
|
5112
|
-
if (msAbs >= m) {
|
|
5113
|
-
return plural(ms2, msAbs, m, "minute");
|
|
5114
|
-
}
|
|
5115
|
-
if (msAbs >= s) {
|
|
5116
|
-
return plural(ms2, msAbs, s, "second");
|
|
5117
|
-
}
|
|
5118
|
-
return ms2 + " ms";
|
|
5119
|
-
}
|
|
5120
|
-
function plural(ms2, msAbs, n, name) {
|
|
5121
|
-
var isPlural = msAbs >= n * 1.5;
|
|
5122
|
-
return Math.round(ms2 / n) + " " + name + (isPlural ? "s" : "");
|
|
5123
|
-
}
|
|
5124
|
-
return ms;
|
|
5125
|
-
}
|
|
5126
|
-
var common;
|
|
5127
|
-
var hasRequiredCommon;
|
|
5128
|
-
function requireCommon() {
|
|
5129
|
-
if (hasRequiredCommon) return common;
|
|
5130
|
-
hasRequiredCommon = 1;
|
|
5131
|
-
function setup(env) {
|
|
5132
|
-
createDebug.debug = createDebug;
|
|
5133
|
-
createDebug.default = createDebug;
|
|
5134
|
-
createDebug.coerce = coerce;
|
|
5135
|
-
createDebug.disable = disable;
|
|
5136
|
-
createDebug.enable = enable;
|
|
5137
|
-
createDebug.enabled = enabled;
|
|
5138
|
-
createDebug.humanize = requireMs();
|
|
5139
|
-
createDebug.destroy = destroy;
|
|
5140
|
-
Object.keys(env).forEach((key) => {
|
|
5141
|
-
createDebug[key] = env[key];
|
|
5142
|
-
});
|
|
5143
|
-
createDebug.names = [];
|
|
5144
|
-
createDebug.skips = [];
|
|
5145
|
-
createDebug.formatters = {};
|
|
5146
|
-
function selectColor(namespace) {
|
|
5147
|
-
let hash = 0;
|
|
5148
|
-
for (let i = 0; i < namespace.length; i++) {
|
|
5149
|
-
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
5150
|
-
hash |= 0;
|
|
5151
|
-
}
|
|
5152
|
-
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
5153
|
-
}
|
|
5154
|
-
createDebug.selectColor = selectColor;
|
|
5155
|
-
function createDebug(namespace) {
|
|
5156
|
-
let prevTime;
|
|
5157
|
-
let enableOverride = null;
|
|
5158
|
-
let namespacesCache;
|
|
5159
|
-
let enabledCache;
|
|
5160
|
-
function debug(...args) {
|
|
5161
|
-
if (!debug.enabled) {
|
|
5162
|
-
return;
|
|
5163
|
-
}
|
|
5164
|
-
const self2 = debug;
|
|
5165
|
-
const curr = Number(/* @__PURE__ */ new Date());
|
|
5166
|
-
const ms2 = curr - (prevTime || curr);
|
|
5167
|
-
self2.diff = ms2;
|
|
5168
|
-
self2.prev = prevTime;
|
|
5169
|
-
self2.curr = curr;
|
|
5170
|
-
prevTime = curr;
|
|
5171
|
-
args[0] = createDebug.coerce(args[0]);
|
|
5172
|
-
if (typeof args[0] !== "string") {
|
|
5173
|
-
args.unshift("%O");
|
|
5174
|
-
}
|
|
5175
|
-
let index = 0;
|
|
5176
|
-
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format2) => {
|
|
5177
|
-
if (match === "%%") {
|
|
5178
|
-
return "%";
|
|
5179
|
-
}
|
|
5180
|
-
index++;
|
|
5181
|
-
const formatter = createDebug.formatters[format2];
|
|
5182
|
-
if (typeof formatter === "function") {
|
|
5183
|
-
const val = args[index];
|
|
5184
|
-
match = formatter.call(self2, val);
|
|
5185
|
-
args.splice(index, 1);
|
|
5186
|
-
index--;
|
|
5187
|
-
}
|
|
5188
|
-
return match;
|
|
5189
|
-
});
|
|
5190
|
-
createDebug.formatArgs.call(self2, args);
|
|
5191
|
-
const logFn = self2.log || createDebug.log;
|
|
5192
|
-
logFn.apply(self2, args);
|
|
5193
|
-
}
|
|
5194
|
-
debug.namespace = namespace;
|
|
5195
|
-
debug.useColors = createDebug.useColors();
|
|
5196
|
-
debug.color = createDebug.selectColor(namespace);
|
|
5197
|
-
debug.extend = extend;
|
|
5198
|
-
debug.destroy = createDebug.destroy;
|
|
5199
|
-
Object.defineProperty(debug, "enabled", {
|
|
5200
|
-
enumerable: true,
|
|
5201
|
-
configurable: false,
|
|
5202
|
-
get: () => {
|
|
5203
|
-
if (enableOverride !== null) {
|
|
5204
|
-
return enableOverride;
|
|
5205
|
-
}
|
|
5206
|
-
if (namespacesCache !== createDebug.namespaces) {
|
|
5207
|
-
namespacesCache = createDebug.namespaces;
|
|
5208
|
-
enabledCache = createDebug.enabled(namespace);
|
|
5209
|
-
}
|
|
5210
|
-
return enabledCache;
|
|
5211
|
-
},
|
|
5212
|
-
set: (v) => {
|
|
5213
|
-
enableOverride = v;
|
|
5214
|
-
}
|
|
5215
|
-
});
|
|
5216
|
-
if (typeof createDebug.init === "function") {
|
|
5217
|
-
createDebug.init(debug);
|
|
5218
|
-
}
|
|
5219
|
-
return debug;
|
|
5220
|
-
}
|
|
5221
|
-
function extend(namespace, delimiter) {
|
|
5222
|
-
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
5223
|
-
newDebug.log = this.log;
|
|
5224
|
-
return newDebug;
|
|
5225
|
-
}
|
|
5226
|
-
function enable(namespaces) {
|
|
5227
|
-
createDebug.save(namespaces);
|
|
5228
|
-
createDebug.namespaces = namespaces;
|
|
5229
|
-
createDebug.names = [];
|
|
5230
|
-
createDebug.skips = [];
|
|
5231
|
-
const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
|
|
5232
|
-
for (const ns of split) {
|
|
5233
|
-
if (ns[0] === "-") {
|
|
5234
|
-
createDebug.skips.push(ns.slice(1));
|
|
5235
|
-
} else {
|
|
5236
|
-
createDebug.names.push(ns);
|
|
5237
|
-
}
|
|
5238
|
-
}
|
|
5239
|
-
}
|
|
5240
|
-
function matchesTemplate(search, template) {
|
|
5241
|
-
let searchIndex = 0;
|
|
5242
|
-
let templateIndex = 0;
|
|
5243
|
-
let starIndex = -1;
|
|
5244
|
-
let matchIndex = 0;
|
|
5245
|
-
while (searchIndex < search.length) {
|
|
5246
|
-
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
|
|
5247
|
-
if (template[templateIndex] === "*") {
|
|
5248
|
-
starIndex = templateIndex;
|
|
5249
|
-
matchIndex = searchIndex;
|
|
5250
|
-
templateIndex++;
|
|
5251
|
-
} else {
|
|
5252
|
-
searchIndex++;
|
|
5253
|
-
templateIndex++;
|
|
5254
|
-
}
|
|
5255
|
-
} else if (starIndex !== -1) {
|
|
5256
|
-
templateIndex = starIndex + 1;
|
|
5257
|
-
matchIndex++;
|
|
5258
|
-
searchIndex = matchIndex;
|
|
5259
|
-
} else {
|
|
5260
|
-
return false;
|
|
5261
|
-
}
|
|
5262
|
-
}
|
|
5263
|
-
while (templateIndex < template.length && template[templateIndex] === "*") {
|
|
5264
|
-
templateIndex++;
|
|
5265
|
-
}
|
|
5266
|
-
return templateIndex === template.length;
|
|
5267
|
-
}
|
|
5268
|
-
function disable() {
|
|
5269
|
-
const namespaces = [
|
|
5270
|
-
...createDebug.names,
|
|
5271
|
-
...createDebug.skips.map((namespace) => "-" + namespace)
|
|
5272
|
-
].join(",");
|
|
5273
|
-
createDebug.enable("");
|
|
5274
|
-
return namespaces;
|
|
5275
|
-
}
|
|
5276
|
-
function enabled(name) {
|
|
5277
|
-
for (const skip of createDebug.skips) {
|
|
5278
|
-
if (matchesTemplate(name, skip)) {
|
|
5279
|
-
return false;
|
|
5280
|
-
}
|
|
5281
|
-
}
|
|
5282
|
-
for (const ns of createDebug.names) {
|
|
5283
|
-
if (matchesTemplate(name, ns)) {
|
|
5284
|
-
return true;
|
|
5285
|
-
}
|
|
5286
|
-
}
|
|
5287
|
-
return false;
|
|
5288
|
-
}
|
|
5289
|
-
function coerce(val) {
|
|
5290
|
-
if (val instanceof Error) {
|
|
5291
|
-
return val.stack || val.message;
|
|
5292
|
-
}
|
|
5293
|
-
return val;
|
|
5294
|
-
}
|
|
5295
|
-
function destroy() {
|
|
5296
|
-
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
5297
|
-
}
|
|
5298
|
-
createDebug.enable(createDebug.load());
|
|
5299
|
-
return createDebug;
|
|
5300
|
-
}
|
|
5301
|
-
common = setup;
|
|
5302
|
-
return common;
|
|
5303
|
-
}
|
|
5304
|
-
var hasRequiredBrowser;
|
|
5305
|
-
function requireBrowser() {
|
|
5306
|
-
if (hasRequiredBrowser) return browser.exports;
|
|
5307
|
-
hasRequiredBrowser = 1;
|
|
5308
|
-
(function(module, exports) {
|
|
5309
|
-
exports.formatArgs = formatArgs;
|
|
5310
|
-
exports.save = save;
|
|
5311
|
-
exports.load = load;
|
|
5312
|
-
exports.useColors = useColors;
|
|
5313
|
-
exports.storage = localstorage();
|
|
5314
|
-
exports.destroy = /* @__PURE__ */ (() => {
|
|
5315
|
-
let warned = false;
|
|
5316
|
-
return () => {
|
|
5317
|
-
if (!warned) {
|
|
5318
|
-
warned = true;
|
|
5319
|
-
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
5320
|
-
}
|
|
5321
|
-
};
|
|
5322
|
-
})();
|
|
5323
|
-
exports.colors = [
|
|
5324
|
-
"#0000CC",
|
|
5325
|
-
"#0000FF",
|
|
5326
|
-
"#0033CC",
|
|
5327
|
-
"#0033FF",
|
|
5328
|
-
"#0066CC",
|
|
5329
|
-
"#0066FF",
|
|
5330
|
-
"#0099CC",
|
|
5331
|
-
"#0099FF",
|
|
5332
|
-
"#00CC00",
|
|
5333
|
-
"#00CC33",
|
|
5334
|
-
"#00CC66",
|
|
5335
|
-
"#00CC99",
|
|
5336
|
-
"#00CCCC",
|
|
5337
|
-
"#00CCFF",
|
|
5338
|
-
"#3300CC",
|
|
5339
|
-
"#3300FF",
|
|
5340
|
-
"#3333CC",
|
|
5341
|
-
"#3333FF",
|
|
5342
|
-
"#3366CC",
|
|
5343
|
-
"#3366FF",
|
|
5344
|
-
"#3399CC",
|
|
5345
|
-
"#3399FF",
|
|
5346
|
-
"#33CC00",
|
|
5347
|
-
"#33CC33",
|
|
5348
|
-
"#33CC66",
|
|
5349
|
-
"#33CC99",
|
|
5350
|
-
"#33CCCC",
|
|
5351
|
-
"#33CCFF",
|
|
5352
|
-
"#6600CC",
|
|
5353
|
-
"#6600FF",
|
|
5354
|
-
"#6633CC",
|
|
5355
|
-
"#6633FF",
|
|
5356
|
-
"#66CC00",
|
|
5357
|
-
"#66CC33",
|
|
5358
|
-
"#9900CC",
|
|
5359
|
-
"#9900FF",
|
|
5360
|
-
"#9933CC",
|
|
5361
|
-
"#9933FF",
|
|
5362
|
-
"#99CC00",
|
|
5363
|
-
"#99CC33",
|
|
5364
|
-
"#CC0000",
|
|
5365
|
-
"#CC0033",
|
|
5366
|
-
"#CC0066",
|
|
5367
|
-
"#CC0099",
|
|
5368
|
-
"#CC00CC",
|
|
5369
|
-
"#CC00FF",
|
|
5370
|
-
"#CC3300",
|
|
5371
|
-
"#CC3333",
|
|
5372
|
-
"#CC3366",
|
|
5373
|
-
"#CC3399",
|
|
5374
|
-
"#CC33CC",
|
|
5375
|
-
"#CC33FF",
|
|
5376
|
-
"#CC6600",
|
|
5377
|
-
"#CC6633",
|
|
5378
|
-
"#CC9900",
|
|
5379
|
-
"#CC9933",
|
|
5380
|
-
"#CCCC00",
|
|
5381
|
-
"#CCCC33",
|
|
5382
|
-
"#FF0000",
|
|
5383
|
-
"#FF0033",
|
|
5384
|
-
"#FF0066",
|
|
5385
|
-
"#FF0099",
|
|
5386
|
-
"#FF00CC",
|
|
5387
|
-
"#FF00FF",
|
|
5388
|
-
"#FF3300",
|
|
5389
|
-
"#FF3333",
|
|
5390
|
-
"#FF3366",
|
|
5391
|
-
"#FF3399",
|
|
5392
|
-
"#FF33CC",
|
|
5393
|
-
"#FF33FF",
|
|
5394
|
-
"#FF6600",
|
|
5395
|
-
"#FF6633",
|
|
5396
|
-
"#FF9900",
|
|
5397
|
-
"#FF9933",
|
|
5398
|
-
"#FFCC00",
|
|
5399
|
-
"#FFCC33"
|
|
5400
|
-
];
|
|
5401
|
-
function useColors() {
|
|
5402
|
-
if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
|
|
5403
|
-
return true;
|
|
5404
|
-
}
|
|
5405
|
-
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
5406
|
-
return false;
|
|
5407
|
-
}
|
|
5408
|
-
let m;
|
|
5409
|
-
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
|
5410
|
-
typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
|
5411
|
-
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
5412
|
-
typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
|
5413
|
-
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
5414
|
-
}
|
|
5415
|
-
function formatArgs(args) {
|
|
5416
|
-
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
|
|
5417
|
-
if (!this.useColors) {
|
|
5418
|
-
return;
|
|
5419
|
-
}
|
|
5420
|
-
const c = "color: " + this.color;
|
|
5421
|
-
args.splice(1, 0, c, "color: inherit");
|
|
5422
|
-
let index = 0;
|
|
5423
|
-
let lastC = 0;
|
|
5424
|
-
args[0].replace(/%[a-zA-Z%]/g, (match) => {
|
|
5425
|
-
if (match === "%%") {
|
|
5426
|
-
return;
|
|
5427
|
-
}
|
|
5428
|
-
index++;
|
|
5429
|
-
if (match === "%c") {
|
|
5430
|
-
lastC = index;
|
|
5431
|
-
}
|
|
5432
|
-
});
|
|
5433
|
-
args.splice(lastC, 0, c);
|
|
5434
|
-
}
|
|
5435
|
-
exports.log = console.debug || console.log || (() => {
|
|
5436
|
-
});
|
|
5437
|
-
function save(namespaces) {
|
|
5438
|
-
try {
|
|
5439
|
-
if (namespaces) {
|
|
5440
|
-
exports.storage.setItem("debug", namespaces);
|
|
5441
|
-
} else {
|
|
5442
|
-
exports.storage.removeItem("debug");
|
|
5443
|
-
}
|
|
5444
|
-
} catch (error) {
|
|
5445
|
-
}
|
|
5446
|
-
}
|
|
5447
|
-
function load() {
|
|
5448
|
-
let r;
|
|
5449
|
-
try {
|
|
5450
|
-
r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
|
|
5451
|
-
} catch (error) {
|
|
5452
|
-
}
|
|
5453
|
-
if (!r && typeof process !== "undefined" && "env" in process) {
|
|
5454
|
-
r = process.env.DEBUG;
|
|
5455
|
-
}
|
|
5456
|
-
return r;
|
|
5457
|
-
}
|
|
5458
|
-
function localstorage() {
|
|
5459
|
-
try {
|
|
5460
|
-
return localStorage;
|
|
5461
|
-
} catch (error) {
|
|
5462
|
-
}
|
|
5463
|
-
}
|
|
5464
|
-
module.exports = requireCommon()(exports);
|
|
5465
|
-
const { formatters } = module.exports;
|
|
5466
|
-
formatters.j = function(v) {
|
|
5467
|
-
try {
|
|
5468
|
-
return JSON.stringify(v);
|
|
5469
|
-
} catch (error) {
|
|
5470
|
-
return "[UnexpectedJSONParseError]: " + error.message;
|
|
5471
|
-
}
|
|
5472
|
-
};
|
|
5473
|
-
})(browser, browser.exports);
|
|
5474
|
-
return browser.exports;
|
|
5475
|
-
}
|
|
5476
|
-
var hasRequiredDist;
|
|
5477
|
-
function requireDist() {
|
|
5478
|
-
if (hasRequiredDist) return dist;
|
|
5479
|
-
hasRequiredDist = 1;
|
|
5480
|
-
var __importDefault = dist && dist.__importDefault || function(mod) {
|
|
5481
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
5482
|
-
};
|
|
5483
|
-
Object.defineProperty(dist, "__esModule", { value: true });
|
|
5484
|
-
dist.NodeClusterAdapter = void 0;
|
|
5485
|
-
dist.createAdapter = createAdapter2;
|
|
5486
|
-
dist.setupPrimary = setupPrimary;
|
|
5487
|
-
const node_cluster_1 = __importDefault(require$$0);
|
|
5488
|
-
const socket_io_adapter_1 = require$$1;
|
|
5489
|
-
const debug_1 = __importDefault(requireBrowser());
|
|
5490
|
-
const debug = (0, debug_1.default)("socket.io-cluster-adapter");
|
|
5491
|
-
const MESSAGE_SOURCE = "_sio_adapter";
|
|
5492
|
-
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
5493
|
-
function ignoreError() {
|
|
5494
|
-
}
|
|
5495
|
-
function createAdapter2(opts = {}) {
|
|
5496
|
-
return function(nsp) {
|
|
5497
|
-
return new NodeClusterAdapter(nsp, opts);
|
|
5498
|
-
};
|
|
5499
|
-
}
|
|
5500
|
-
class NodeClusterAdapter extends socket_io_adapter_1.ClusterAdapterWithHeartbeat {
|
|
5501
|
-
constructor(nsp, opts = {}) {
|
|
5502
|
-
super(nsp, opts);
|
|
5503
|
-
process.on("message", (message) => {
|
|
5504
|
-
const isValidSource = (message === null || message === void 0 ? void 0 : message.source) === MESSAGE_SOURCE;
|
|
5505
|
-
if (!isValidSource) {
|
|
5506
|
-
debug("[%s] ignore unknown source", this.uid);
|
|
5507
|
-
return;
|
|
5508
|
-
}
|
|
5509
|
-
if (message.nsp !== this.nsp.name) {
|
|
5510
|
-
debug("[%s] ignore other namespace", this.uid);
|
|
5511
|
-
return;
|
|
5512
|
-
}
|
|
5513
|
-
this.onMessage(message);
|
|
5514
|
-
});
|
|
5515
|
-
this.init();
|
|
5516
|
-
}
|
|
5517
|
-
doPublish(message) {
|
|
5518
|
-
message.source = MESSAGE_SOURCE;
|
|
5519
|
-
process.send(message, null, {}, ignoreError);
|
|
5520
|
-
return Promise.resolve("");
|
|
5521
|
-
}
|
|
5522
|
-
doPublishResponse(requesterUid, response) {
|
|
5523
|
-
response.source = MESSAGE_SOURCE;
|
|
5524
|
-
response.requesterUid = requesterUid;
|
|
5525
|
-
process.send(response, null, {}, ignoreError);
|
|
5526
|
-
return Promise.resolve();
|
|
5527
|
-
}
|
|
5528
|
-
}
|
|
5529
|
-
dist.NodeClusterAdapter = NodeClusterAdapter;
|
|
5530
|
-
const UIDS = /* @__PURE__ */ Symbol("uids");
|
|
5531
|
-
function setupPrimary() {
|
|
5532
|
-
node_cluster_1.default.on("message", (worker, message) => {
|
|
5533
|
-
var _a;
|
|
5534
|
-
const isValidSource = (message === null || message === void 0 ? void 0 : message.source) === MESSAGE_SOURCE;
|
|
5535
|
-
if (!isValidSource) {
|
|
5536
|
-
return;
|
|
5537
|
-
}
|
|
5538
|
-
worker[UIDS] = worker[UIDS] || /* @__PURE__ */ new Set();
|
|
5539
|
-
worker[UIDS].add(message.uid);
|
|
5540
|
-
switch (message.type) {
|
|
5541
|
-
case socket_io_adapter_1.MessageType.FETCH_SOCKETS_RESPONSE:
|
|
5542
|
-
case socket_io_adapter_1.MessageType.SERVER_SIDE_EMIT_RESPONSE:
|
|
5543
|
-
const requesterUid = message.requesterUid;
|
|
5544
|
-
for (const workerId in node_cluster_1.default.workers) {
|
|
5545
|
-
if (hasOwnProperty.call(node_cluster_1.default.workers, workerId) && ((_a = node_cluster_1.default.workers[workerId][UIDS]) === null || _a === void 0 ? void 0 : _a.has(requesterUid))) {
|
|
5546
|
-
node_cluster_1.default.workers[workerId].send(message, null, ignoreError);
|
|
5547
|
-
break;
|
|
5548
|
-
}
|
|
5549
|
-
}
|
|
5550
|
-
break;
|
|
5551
|
-
default:
|
|
5552
|
-
const emitterIdAsString = String(worker.id);
|
|
5553
|
-
for (const workerId in node_cluster_1.default.workers) {
|
|
5554
|
-
if (hasOwnProperty.call(node_cluster_1.default.workers, workerId) && workerId !== emitterIdAsString) {
|
|
5555
|
-
node_cluster_1.default.workers[workerId].send(message, null, ignoreError);
|
|
5556
|
-
}
|
|
5557
|
-
}
|
|
5558
|
-
}
|
|
5559
|
-
});
|
|
5560
|
-
}
|
|
5561
|
-
return dist;
|
|
5562
|
-
}
|
|
5563
|
-
var distExports = requireDist();
|
|
5564
|
-
class SocketIoServer extends tinyEmitterExports.TinyEmitter {
|
|
5565
|
-
namespace;
|
|
5566
|
-
socketionamespace;
|
|
5567
|
-
//protected socketionamespace?: Namespace<ClientToServerEvents, ServerToClientEvents, InterServerEvents>
|
|
5568
|
-
logger;
|
|
5569
|
-
io;
|
|
5570
|
-
//#redisClient: RedisClientType | Redis | null = null;
|
|
5571
|
-
redisClient;
|
|
5572
|
-
listenPort;
|
|
5573
|
-
socketIoCustomPath;
|
|
5574
|
-
ioRedisMessageProcessorUrl;
|
|
5575
|
-
serverClusterMode;
|
|
5576
|
-
rooms;
|
|
5577
|
-
constructor() {
|
|
5578
|
-
super();
|
|
5579
|
-
}
|
|
5580
|
-
LogErrorMessage(message) {
|
|
5581
|
-
if (this.logger) {
|
|
5582
|
-
this.logger.error(`${this.namespace}: ${message}`);
|
|
5583
|
-
}
|
|
5584
|
-
}
|
|
5585
|
-
LogDebugMessage(message) {
|
|
5586
|
-
if (this.logger) {
|
|
5587
|
-
this.logger.debug(`${this.namespace}: ${message}`);
|
|
5588
|
-
}
|
|
5589
|
-
}
|
|
5590
|
-
LogInfoMessage(message) {
|
|
5591
|
-
if (this.logger) {
|
|
5592
|
-
this.logger.info(`${this.namespace}: ${message}`);
|
|
5593
|
-
}
|
|
5594
|
-
}
|
|
5595
|
-
LogWarnMessage(message) {
|
|
5596
|
-
if (this.logger) {
|
|
5597
|
-
this.logger.warn(`${this.namespace}: ${message}`);
|
|
5598
|
-
}
|
|
5599
|
-
}
|
|
5600
|
-
// https://socket.io/docs/v4/middlewares/
|
|
5601
|
-
// https://socket.io/docs/v4/server-socket-instance/#sockethandshake
|
|
5602
|
-
// https://socket.io/docs/v4/server-socket-instance/#socket-middlewares
|
|
5603
|
-
// Use this middleward to check every incomming connection
|
|
5604
|
-
SetupConnectionMiddleware = () => {
|
|
5605
|
-
};
|
|
5606
|
-
// Use this middleware to check every packet being received
|
|
5607
|
-
SetupMessageMiddleware = (socket) => {
|
|
5608
|
-
};
|
|
5609
|
-
SocketConnectCallBack = (socket) => {
|
|
5610
|
-
};
|
|
5611
|
-
SocketEventsCallBack = (socket) => {
|
|
5612
|
-
};
|
|
5613
|
-
GetConfig = (socketIoServeroptions) => {
|
|
5614
|
-
const options = {
|
|
5615
|
-
transports: ["websocket"]
|
|
5616
|
-
// or [ "websocket", "polling" ] (to use long-poolling. Note that the order matters)
|
|
5617
|
-
};
|
|
5618
|
-
if (socketIoServeroptions.ioRedisMessageProcessorUrl && socketIoServeroptions.ioRedisMessageProcessorUrl !== "") {
|
|
5619
|
-
this.redisClient = new Redis(socketIoServeroptions.ioRedisMessageProcessorUrl);
|
|
5620
|
-
options.adapter = createAdapter(this.redisClient);
|
|
5621
|
-
} else if (socketIoServeroptions.serverClusterMode && socketIoServeroptions.serverClusterMode === true) {
|
|
5622
|
-
options.adapter = distExports.createAdapter();
|
|
5623
|
-
}
|
|
5624
|
-
if (socketIoServeroptions.wssCustomPath && socketIoServeroptions.wssCustomPath.localeCompare("") !== 0) {
|
|
5625
|
-
options.path = socketIoServeroptions.wssCustomPath;
|
|
5626
|
-
}
|
|
5627
|
-
return options;
|
|
5628
|
-
};
|
|
5629
|
-
SetEngineEvents = () => {
|
|
5630
|
-
if (this.io) {
|
|
5631
|
-
this.io.engine.on("connection_error", (err) => {
|
|
5632
|
-
this.LogInfoMessage(err.req);
|
|
5633
|
-
this.LogInfoMessage(err.code);
|
|
5634
|
-
this.LogInfoMessage(err.message);
|
|
5635
|
-
this.LogInfoMessage(err.context);
|
|
5636
|
-
});
|
|
5637
|
-
}
|
|
5638
|
-
};
|
|
5639
|
-
WithLogger = (logger) => {
|
|
5640
|
-
this.logger = logger;
|
|
5641
|
-
return this;
|
|
5642
|
-
};
|
|
5643
|
-
WithExistingServer = (server) => {
|
|
5644
|
-
if (this.io) {
|
|
5645
|
-
throw new Error(`SocketIoServer:AttachServer(): Error: [Server already attached]`);
|
|
5646
|
-
}
|
|
5647
|
-
this.io = server;
|
|
5648
|
-
return this;
|
|
5649
|
-
};
|
|
5650
|
-
WithListenPort = (listenPort) => {
|
|
5651
|
-
this.listenPort = listenPort;
|
|
5652
|
-
return this;
|
|
5653
|
-
};
|
|
5654
|
-
WithSocketIoCustomPath = (socketIoCustomPath) => {
|
|
5655
|
-
this.socketIoCustomPath = socketIoCustomPath;
|
|
5656
|
-
return this;
|
|
5657
|
-
};
|
|
5658
|
-
WithIoRedisMessageProcessorUrl = (ioRedisMessageProcessorUrl) => {
|
|
5659
|
-
this.ioRedisMessageProcessorUrl = ioRedisMessageProcessorUrl;
|
|
5660
|
-
return this;
|
|
5661
|
-
};
|
|
5662
|
-
WithClusterMode = (serverClusterMode) => {
|
|
5663
|
-
this.serverClusterMode = serverClusterMode;
|
|
5664
|
-
return this;
|
|
5665
|
-
};
|
|
5666
|
-
WithRooms = (rooms) => {
|
|
5667
|
-
this.rooms = rooms;
|
|
5668
|
-
return this;
|
|
5669
|
-
};
|
|
5670
|
-
WithNamespace = (namespace) => {
|
|
5671
|
-
this.namespace = namespace;
|
|
5672
|
-
return this;
|
|
5673
|
-
};
|
|
5674
|
-
StartServer = async () => {
|
|
5675
|
-
if (!this.namespace) {
|
|
5676
|
-
throw new Error(`SocketIoServer:StartServer(): Error: [namespace not specified]`);
|
|
5677
|
-
}
|
|
5678
|
-
if (!this.io) {
|
|
5679
|
-
if (!this.listenPort) {
|
|
5680
|
-
throw new Error(`SocketIoServer:StartServer(): Error: [listenPort not specified]`);
|
|
5681
|
-
}
|
|
5682
|
-
const options = {
|
|
5683
|
-
transports: ["websocket"]
|
|
5684
|
-
// or [ "websocket", "polling" ] (to use long-poolling. Note that the order matters)
|
|
5685
|
-
};
|
|
5686
|
-
if (this.ioRedisMessageProcessorUrl && this.ioRedisMessageProcessorUrl !== "") {
|
|
5687
|
-
this.redisClient = new Redis(this.ioRedisMessageProcessorUrl);
|
|
5688
|
-
options.adapter = createAdapter(this.redisClient);
|
|
5689
|
-
} else if (this.serverClusterMode && this.serverClusterMode === true) {
|
|
5690
|
-
options.adapter = distExports.createAdapter();
|
|
5691
|
-
}
|
|
5692
|
-
if (this.socketIoCustomPath && this.socketIoCustomPath.localeCompare("") !== 0) {
|
|
5693
|
-
options.path = this.socketIoCustomPath;
|
|
5694
|
-
}
|
|
5695
|
-
this.io = new Server(this.listenPort, options);
|
|
5696
|
-
this.SetEngineEvents();
|
|
5697
|
-
await Sleep(500);
|
|
5698
|
-
}
|
|
5699
|
-
let autoJoinRooms;
|
|
5700
|
-
let rooms;
|
|
5701
|
-
if (this.rooms && this.rooms.length > 0) {
|
|
5702
|
-
autoJoinRooms = true;
|
|
5703
|
-
rooms = [...this.rooms];
|
|
5704
|
-
} else {
|
|
5705
|
-
autoJoinRooms = false;
|
|
5706
|
-
rooms = [];
|
|
5707
|
-
}
|
|
5708
|
-
this.SetupNamespace(rooms, autoJoinRooms);
|
|
5709
|
-
return this;
|
|
5710
|
-
};
|
|
5711
|
-
AttachServer = async (server) => {
|
|
5712
|
-
if (this.io) {
|
|
5713
|
-
throw new Error(`SocketIoServer:AttachServer(): Error: [Server already attached]`);
|
|
5714
|
-
}
|
|
5715
|
-
this.io = server;
|
|
5716
|
-
};
|
|
5717
|
-
StopServer = async () => {
|
|
5718
|
-
if (this.io) {
|
|
5719
|
-
await this.CloseNamespaceAdaptors();
|
|
5720
|
-
this.DisconnectNamespaceSockets();
|
|
5721
|
-
await this.io.of("/").adapter.close();
|
|
5722
|
-
if (this.redisClient) {
|
|
5723
|
-
await this.redisClient.disconnect();
|
|
5724
|
-
await Sleep(50);
|
|
5725
|
-
}
|
|
5726
|
-
this.io.disconnectSockets();
|
|
5727
|
-
this.io = void 0;
|
|
5728
|
-
}
|
|
5729
|
-
};
|
|
5730
|
-
LeaveRoom = (socket, room) => {
|
|
5731
|
-
this.LogDebugMessage(`Leaving room [${room}]`);
|
|
5732
|
-
socket.leave(room);
|
|
5733
|
-
};
|
|
5734
|
-
JoinRoom = (socket, room) => {
|
|
5735
|
-
this.LogDebugMessage(`Socket joining room [${room}], ID: [${socket.id}]`);
|
|
5736
|
-
socket.join(room);
|
|
5737
|
-
};
|
|
5738
|
-
SetupStandardEvents = (socket) => {
|
|
5739
|
-
socket.on("disconnect", (reason) => {
|
|
5740
|
-
this.LogDebugMessage(`socket disconnect, ID: [${socket.id}] [${reason}]`);
|
|
5741
|
-
});
|
|
5742
|
-
socket.on("disconnecting", (reason) => {
|
|
5743
|
-
this.LogDebugMessage(`socket disconnecting, ID: [${socket.id}] [${reason}]`);
|
|
5744
|
-
});
|
|
5745
|
-
socket.on("error", (error) => {
|
|
5746
|
-
this.LogDebugMessage(`socket error, ID: [${socket.id}] [${error}]`);
|
|
5747
|
-
});
|
|
5748
|
-
socket.on("__STSdisconnect", (reason) => {
|
|
5749
|
-
this.LogDebugMessage(`__STSdisconnect: socket disconnect, ID: [${socket.id}] [${reason}]`);
|
|
5750
|
-
});
|
|
5751
|
-
socket.on("__STSdisconnecting", (reason, callBackResult) => {
|
|
5752
|
-
this.LogDebugMessage(`__STSdisconnecting: socket disconnecting, ID: [${socket.id}] [${reason}]`);
|
|
5753
|
-
callBackResult("__STSdisconnecting accepted by server.");
|
|
5754
|
-
});
|
|
5755
|
-
socket.on("__STSjoinRoom", (rooms) => {
|
|
5756
|
-
rooms.forEach((room) => {
|
|
5757
|
-
this.JoinRoom(socket, room);
|
|
5758
|
-
});
|
|
5759
|
-
});
|
|
5760
|
-
socket.on("__STSleaveRoom", (rooms) => {
|
|
5761
|
-
rooms.forEach((room) => {
|
|
5762
|
-
this.LeaveRoom(socket, room);
|
|
5763
|
-
});
|
|
5764
|
-
});
|
|
5765
|
-
socket.on("__STSsendToRoom", (rooms, payload) => {
|
|
5766
|
-
rooms.forEach((room) => {
|
|
5767
|
-
if (this.socketionamespace) {
|
|
5768
|
-
this.LogDebugMessage(`socket.on: __STSsendToRoom: Sending to room [${room}], ID: [${socket.id}]`);
|
|
5769
|
-
this.socketionamespace.to(room).emit(payload.command, payload);
|
|
5770
|
-
}
|
|
5771
|
-
});
|
|
5772
|
-
});
|
|
5773
|
-
socket.on("__STSsendToRoomWithCallback", (room, timeout, payload, cb) => {
|
|
5774
|
-
if (this.socketionamespace) {
|
|
5775
|
-
this.socketionamespace.to(room).timeout(timeout).emit(payload.command, payload, (err, dataResponse) => {
|
|
5776
|
-
if (err) {
|
|
5777
|
-
console.error(err);
|
|
5778
|
-
const errorResponse = {
|
|
5779
|
-
error: true,
|
|
5780
|
-
errorName: err.name,
|
|
5781
|
-
errorMessage: err.message
|
|
5782
|
-
//errorCause: err.cause,
|
|
5783
|
-
//errorStack: err.stack
|
|
5784
|
-
};
|
|
5785
|
-
this.LogErrorMessage(`__STSsendToRoomWithCallback broadcast (error): [${JSON.stringify(errorResponse)}]`);
|
|
5786
|
-
cb(errorResponse);
|
|
5787
|
-
} else {
|
|
5788
|
-
this.LogDebugMessage(`__STSsendToRoomWithCallback broadcast: [${JSON.stringify(dataResponse)}]`);
|
|
5789
|
-
cb(dataResponse);
|
|
5790
|
-
}
|
|
5791
|
-
});
|
|
5792
|
-
}
|
|
5793
|
-
});
|
|
5794
|
-
socket.on("__STSsendToRoomsWithCallback", (rooms, timeout, payload, cb) => {
|
|
5795
|
-
const responses = [];
|
|
5796
|
-
const timeoutForComplete = setTimeout(() => {
|
|
5797
|
-
responses.push({
|
|
5798
|
-
room: "",
|
|
5799
|
-
responses: {
|
|
5800
|
-
error: true,
|
|
5801
|
-
errorName: "timeout",
|
|
5802
|
-
errorMessage: `__STSsendToRoomsWithCallback timeout: [${timeout}] before all responses received`
|
|
5803
|
-
}
|
|
5804
|
-
});
|
|
5805
|
-
cb(responses);
|
|
5806
|
-
}, timeout).unref();
|
|
5807
|
-
rooms.forEach((room) => {
|
|
5808
|
-
if (this.socketionamespace) {
|
|
5809
|
-
this.socketionamespace.to(room).timeout(timeout).emit(payload.command, payload, (err, dataResponse) => {
|
|
5810
|
-
if (err) {
|
|
5811
|
-
console.error(err);
|
|
5812
|
-
const errorResponse = {
|
|
5813
|
-
error: true,
|
|
5814
|
-
errorName: err.name,
|
|
5815
|
-
errorMessage: err.message
|
|
5816
|
-
//errorCause: err.cause,
|
|
5817
|
-
//errorStack: err.stack
|
|
5818
|
-
};
|
|
5819
|
-
this.LogErrorMessage(`__STSsendToRoomWithCallback broadcast (error): [${JSON.stringify(errorResponse)}]`);
|
|
5820
|
-
responses.push({
|
|
5821
|
-
room,
|
|
5822
|
-
responses: errorResponse
|
|
5823
|
-
});
|
|
5824
|
-
} else {
|
|
5825
|
-
this.LogDebugMessage(`__STSsendToRoomWithCallback broadcast: [${JSON.stringify(dataResponse)}]`);
|
|
5826
|
-
responses.push({
|
|
5827
|
-
room,
|
|
5828
|
-
responses: dataResponse
|
|
5829
|
-
});
|
|
5830
|
-
}
|
|
5831
|
-
if (responses.length === rooms.length) {
|
|
5832
|
-
clearTimeout(timeoutForComplete);
|
|
5833
|
-
cb(responses);
|
|
5834
|
-
}
|
|
5835
|
-
});
|
|
5836
|
-
}
|
|
5837
|
-
});
|
|
5838
|
-
});
|
|
5839
|
-
};
|
|
5840
|
-
SetupNamespace = (rooms, autoJoinRooms) => {
|
|
5841
|
-
if (this.io) {
|
|
5842
|
-
this.socketionamespace = this.io.of(`/${this.namespace}/`);
|
|
5843
|
-
this.SetupConnectionMiddleware();
|
|
5844
|
-
this.socketionamespace.on("connection", (socket) => {
|
|
5845
|
-
this.LogDebugMessage(`Socket connected, ID: [${socket.id}]`);
|
|
5846
|
-
this.LogDebugMessage(`Authentication Handshake (auth): [${JSON.stringify(socket.handshake.auth)}]`);
|
|
5847
|
-
this.LogDebugMessage(`Authentication Handshake (host): [${JSON.stringify(socket.handshake.headers.host)}]`);
|
|
5848
|
-
this.LogDebugMessage(`Authentication Handshake (url): [${JSON.stringify(socket.handshake.url)}]`);
|
|
5849
|
-
this.LogDebugMessage(`Authentication Handshake: [${JSON.stringify(socket.handshake)}]`);
|
|
5850
|
-
this.SetupMessageMiddleware(socket);
|
|
5851
|
-
if (autoJoinRooms) {
|
|
5852
|
-
rooms.map((room) => {
|
|
5853
|
-
this.JoinRoom(socket, room);
|
|
5854
|
-
});
|
|
5855
|
-
}
|
|
5856
|
-
this.SetupStandardEvents(socket);
|
|
5857
|
-
setTimeout(() => {
|
|
5858
|
-
this.SocketConnectCallBack(socket);
|
|
5859
|
-
}, 0);
|
|
5860
|
-
this.SocketEventsCallBack(socket);
|
|
5861
|
-
});
|
|
5862
|
-
} else {
|
|
5863
|
-
throw new Error("SocketIoServer:SetupNamespace(): Error: [No server attached");
|
|
5864
|
-
}
|
|
5865
|
-
return this;
|
|
5866
|
-
};
|
|
5867
|
-
CloseNamespaceAdaptors = async () => {
|
|
5868
|
-
if (this.socketionamespace) {
|
|
5869
|
-
await this.socketionamespace.adapter.close();
|
|
5870
|
-
}
|
|
5871
|
-
};
|
|
5872
|
-
DisconnectNamespaceSockets = () => {
|
|
5873
|
-
if (this.socketionamespace) {
|
|
5874
|
-
this.socketionamespace.disconnectSockets();
|
|
5875
|
-
this.socketionamespace = void 0;
|
|
5876
|
-
}
|
|
5877
|
-
};
|
|
5878
|
-
}
|
|
5879
5002
|
const byteToHex = [];
|
|
5880
5003
|
for (let i = 0; i < 256; ++i) {
|
|
5881
5004
|
byteToHex.push((i + 256).toString(16).slice(1));
|
|
@@ -6254,8 +5377,8 @@ class FhirSocketClient extends SocketIoClient {
|
|
|
6254
5377
|
return (await prom()).value;
|
|
6255
5378
|
};
|
|
6256
5379
|
}
|
|
6257
|
-
function sleep(
|
|
6258
|
-
return new Promise((resolve2) => setTimeout(resolve2,
|
|
5380
|
+
function sleep(ms) {
|
|
5381
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
6259
5382
|
}
|
|
6260
5383
|
function getJitteredDelay(base, jitter) {
|
|
6261
5384
|
const random = Math.floor(Math.random() * jitter);
|