@nsshunt/stsrunnerframework 2.0.30 → 2.0.31
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/index.cjs +50 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +50 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -9975,6 +9975,7 @@ var SocketIoClient = class extends import_tiny_emitter.TinyEmitter {
|
|
|
9975
9975
|
#socket;
|
|
9976
9976
|
#reconnectTimeout = 2e3;
|
|
9977
9977
|
#ackTimeout = 5e3;
|
|
9978
|
+
#reconnectTimeoutVal = void 0;
|
|
9978
9979
|
constructor(name) {
|
|
9979
9980
|
super();
|
|
9980
9981
|
this.#name = name;
|
|
@@ -10047,7 +10048,7 @@ var SocketIoClient = class extends import_tiny_emitter.TinyEmitter {
|
|
|
10047
10048
|
return this;
|
|
10048
10049
|
}
|
|
10049
10050
|
SetupSocket() {
|
|
10050
|
-
if (!this.#address) throw new Error(`
|
|
10051
|
+
if (!this.#address) throw new Error(`SocketIoClient:SetupSocket(): Error: [address not provided]`);
|
|
10051
10052
|
this.#EstablishSocketConnect();
|
|
10052
10053
|
return this;
|
|
10053
10054
|
}
|
|
@@ -10057,17 +10058,20 @@ var SocketIoClient = class extends import_tiny_emitter.TinyEmitter {
|
|
|
10057
10058
|
EngineReconnect(attempt) {}
|
|
10058
10059
|
#EstablishSocketConnect() {
|
|
10059
10060
|
if (this.#socket !== void 0) {
|
|
10060
|
-
|
|
10061
|
-
this.#
|
|
10062
|
-
|
|
10063
|
-
else setTimeout(() => this.#EstablishSocketConnect(), this.#reconnectTimeout);
|
|
10061
|
+
this.ResetSocket();
|
|
10062
|
+
if (_nsshunt_stsutils.isNode) this.#reconnectTimeoutVal = setTimeout(() => this.#EstablishSocketConnect(), this.#reconnectTimeout).unref();
|
|
10063
|
+
else this.#reconnectTimeoutVal = setTimeout(() => this.#EstablishSocketConnect(), this.#reconnectTimeout);
|
|
10064
10064
|
return;
|
|
10065
10065
|
}
|
|
10066
10066
|
let socketOptions;
|
|
10067
10067
|
if (_nsshunt_stsutils.isNode) {
|
|
10068
10068
|
socketOptions = { transports: ["websocket"] };
|
|
10069
10069
|
if (this.#agentManager) {
|
|
10070
|
-
if (!this.#address)
|
|
10070
|
+
if (!this.#address) {
|
|
10071
|
+
const message = `SocketIoClient:#EstablishSocketConnect(): Error: [address not provided when using agentManager]`;
|
|
10072
|
+
this.LogErrorMessage(message);
|
|
10073
|
+
throw new Error(message);
|
|
10074
|
+
}
|
|
10071
10075
|
socketOptions.agent = this.#agentManager.GetAgent(this.#address);
|
|
10072
10076
|
}
|
|
10073
10077
|
} else socketOptions = { transports: ["websocket"] };
|
|
@@ -10078,30 +10082,30 @@ var SocketIoClient = class extends import_tiny_emitter.TinyEmitter {
|
|
|
10078
10082
|
if (this.#socketIoCustomPath && this.#socketIoCustomPath.localeCompare("") !== 0) socketOptions.path = this.#socketIoCustomPath;
|
|
10079
10083
|
this.#socket = lookup(this.#address, socketOptions);
|
|
10080
10084
|
this.#socket.io.on("error", (err) => {
|
|
10081
|
-
this.LogErrorMessage(`
|
|
10085
|
+
this.LogErrorMessage(`SocketIoClient.socket.io.on('error'): [${err}] Address: [${this.#address}]`);
|
|
10082
10086
|
this.EngineError(err);
|
|
10083
10087
|
});
|
|
10084
10088
|
this.#socket.io.on("reconnect_error", (err) => {
|
|
10085
|
-
this.LogErrorMessage(`
|
|
10089
|
+
this.LogErrorMessage(`SocketIoClient.socket.io.on('reconnect_error'): [${err}] Address: [${this.#address}]`);
|
|
10086
10090
|
this.EngineReconnectError(err);
|
|
10087
10091
|
});
|
|
10088
10092
|
this.#socket.on("connect_error", (err) => {
|
|
10089
|
-
this.LogErrorMessage(`
|
|
10093
|
+
this.LogErrorMessage(`SocketIoClient.socket.on('connect_error'): [${err}] Address: [${this.#address}]`);
|
|
10090
10094
|
this.EngineConnectError(err);
|
|
10091
10095
|
});
|
|
10092
10096
|
this.#socket.io.on("reconnect", (attempt) => {
|
|
10093
|
-
this.LogErrorMessage(`
|
|
10097
|
+
this.LogErrorMessage(`SocketIoClient:socket.io.on('reconnect'): Number: [${attempt}] Address: [${this.#address}]`);
|
|
10094
10098
|
this.EngineReconnect(attempt);
|
|
10095
10099
|
});
|
|
10096
10100
|
this.#socket.on("connect", () => {
|
|
10097
10101
|
if (this.#socket) {
|
|
10098
|
-
this.LogDebugMessage(`Socket: [${this.#socket.id}]: connected, Address: [${this.#address}]`);
|
|
10102
|
+
this.LogDebugMessage(`SocketIoClient:on("connect"): Socket: [${this.#socket.id}]: connected, Address: [${this.#address}]`);
|
|
10099
10103
|
setTimeout(() => {
|
|
10100
10104
|
this.SocketConnect(this.#socket);
|
|
10101
10105
|
}, 0);
|
|
10102
10106
|
this.SetupSocketEvents(this.#socket);
|
|
10103
10107
|
} else {
|
|
10104
|
-
const errorMessage = "Could not get socket object from socket.io, Address: [${socketDetail.address}]";
|
|
10108
|
+
const errorMessage = "SocketIoClient:on(\"connect\"): Could not get socket object from socket.io, Address: [${socketDetail.address}]";
|
|
10105
10109
|
this.LogErrorMessage(errorMessage);
|
|
10106
10110
|
this.SocketConnectError(new Error(errorMessage));
|
|
10107
10111
|
}
|
|
@@ -10111,33 +10115,50 @@ var SocketIoClient = class extends import_tiny_emitter.TinyEmitter {
|
|
|
10111
10115
|
this.SocketDisconnect(reason);
|
|
10112
10116
|
switch (reason) {
|
|
10113
10117
|
case "io server disconnect":
|
|
10114
|
-
this.LogDebugMessage("The server disconnected using disconnectSockets, i.e. normal safe shutdown from explicit disconnection by the server.");
|
|
10115
|
-
this.LogDebugMessage("The connection will be re-established when the server becomes available.");
|
|
10116
|
-
this
|
|
10117
|
-
if (_nsshunt_stsutils.isNode)
|
|
10118
|
-
|
|
10119
|
-
setTimeout(() => this.#EstablishSocketConnect(), this.#reconnectTimeout).unref();
|
|
10120
|
-
} else setTimeout(() => this.#EstablishSocketConnect(), this.#reconnectTimeout);
|
|
10118
|
+
this.LogDebugMessage("SocketIoClient:on(\"disconnect\"): The server disconnected using disconnectSockets, i.e. normal safe shutdown from explicit disconnection by the server.");
|
|
10119
|
+
this.LogDebugMessage("SocketIoClient:on(\"disconnect\"): The connection will be re-established when the server becomes available.");
|
|
10120
|
+
this.ResetSocket();
|
|
10121
|
+
if (_nsshunt_stsutils.isNode) this.#reconnectTimeoutVal = setTimeout(() => this.#EstablishSocketConnect(), this.#reconnectTimeout).unref();
|
|
10122
|
+
else this.#reconnectTimeoutVal = setTimeout(() => this.#EstablishSocketConnect(), this.#reconnectTimeout);
|
|
10121
10123
|
break;
|
|
10122
10124
|
case "io client disconnect":
|
|
10123
|
-
this.LogDebugMessage("The client disconnected using disconnectSockets, i.e. normal safe disconnection from explicit disconnection by the client.");
|
|
10124
|
-
this.LogDebugMessage("The connection will not be re-established automatically.");
|
|
10125
|
+
this.LogDebugMessage("SocketIoClient:on(\"disconnect\"): The client disconnected using disconnectSockets, i.e. normal safe disconnection from explicit disconnection by the client.");
|
|
10126
|
+
this.LogDebugMessage("SocketIoClient:on(\"disconnect\"): The connection will not be re-established automatically.");
|
|
10127
|
+
this.ResetSocket();
|
|
10125
10128
|
break;
|
|
10126
10129
|
case "transport close":
|
|
10127
10130
|
case "ping timeout":
|
|
10128
10131
|
case "transport error":
|
|
10129
|
-
this.LogDebugMessage(`Server unexpectedly disconnected. Reason: [${reason}]`);
|
|
10130
|
-
this.LogDebugMessage("The connection will be re-established when the server becomes available.");
|
|
10131
|
-
|
|
10132
|
-
this.#
|
|
10133
|
-
|
|
10134
|
-
if (this.#agentManager) this.#agentManager?.ResetAgent();
|
|
10135
|
-
setTimeout(() => this.#EstablishSocketConnect(), this.#reconnectTimeout).unref();
|
|
10136
|
-
} else setTimeout(() => this.#EstablishSocketConnect(), this.#reconnectTimeout);
|
|
10132
|
+
this.LogDebugMessage(`SocketIoClient:on("disconnect"): Server unexpectedly disconnected. Reason: [${reason}]`);
|
|
10133
|
+
this.LogDebugMessage("SocketIoClient:on(\"disconnect\"): The connection will be re-established when the server becomes available.");
|
|
10134
|
+
this.ResetSocket();
|
|
10135
|
+
if (_nsshunt_stsutils.isNode) this.#reconnectTimeoutVal = setTimeout(() => this.#EstablishSocketConnect(), this.#reconnectTimeout).unref();
|
|
10136
|
+
else this.#reconnectTimeoutVal = setTimeout(() => this.#EstablishSocketConnect(), this.#reconnectTimeout);
|
|
10137
10137
|
break;
|
|
10138
10138
|
}
|
|
10139
10139
|
});
|
|
10140
10140
|
}
|
|
10141
|
+
ResetSocket = () => {
|
|
10142
|
+
try {
|
|
10143
|
+
if (this.#reconnectTimeoutVal !== void 0) {
|
|
10144
|
+
clearTimeout(this.#reconnectTimeoutVal);
|
|
10145
|
+
this.#reconnectTimeoutVal = void 0;
|
|
10146
|
+
}
|
|
10147
|
+
if (this.#socket) {
|
|
10148
|
+
this.#socket.removeAllListeners();
|
|
10149
|
+
this.#socket.io.removeAllListeners();
|
|
10150
|
+
if (this.#socket.connected === true) this.#socket.disconnect();
|
|
10151
|
+
if (_nsshunt_stsutils.isNode) {
|
|
10152
|
+
if (this.#agentManager) this.#agentManager.ResetAgent();
|
|
10153
|
+
}
|
|
10154
|
+
this.#socket = void 0;
|
|
10155
|
+
}
|
|
10156
|
+
} catch (error) {
|
|
10157
|
+
const errorMessage = `SocketIoClient:ResetSocket(): Error: [${error}]`;
|
|
10158
|
+
this.LogErrorMessage(errorMessage);
|
|
10159
|
+
this.SocketConnectError(new Error(errorMessage));
|
|
10160
|
+
}
|
|
10161
|
+
};
|
|
10141
10162
|
};
|
|
10142
10163
|
//#endregion
|
|
10143
10164
|
//#region src/wsevents.ts
|