@nsshunt/stsfhirclient 1.1.17 → 1.1.18
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.cjs +38 -22
- package/dist/stsfhirclient.cjs.map +1 -1
- package/dist/stsfhirclient.mjs +38 -22
- package/dist/stsfhirclient.mjs.map +1 -1
- package/package.json +6 -6
package/dist/stsfhirclient.cjs
CHANGED
|
@@ -4812,21 +4812,33 @@ class SocketIoClient extends tinyEmitterExports.TinyEmitter {
|
|
|
4812
4812
|
#socketIoCustomPath;
|
|
4813
4813
|
#authToken;
|
|
4814
4814
|
#socket;
|
|
4815
|
+
#reconnectTimeout = 2e3;
|
|
4816
|
+
// default
|
|
4815
4817
|
constructor(name) {
|
|
4816
4818
|
super();
|
|
4817
4819
|
this.#name = name;
|
|
4818
4820
|
}
|
|
4821
|
+
get logPrefix() {
|
|
4822
|
+
return `SocketIoClient[${this.#name}]:`;
|
|
4823
|
+
}
|
|
4819
4824
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4820
4825
|
LogDebugMessage(message) {
|
|
4821
|
-
if (this.#logger) this.#logger.debug(message);
|
|
4826
|
+
if (this.#logger) this.#logger.debug(`${this.logPrefix}${message}`);
|
|
4822
4827
|
}
|
|
4823
4828
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4824
4829
|
LogErrorMessage(message) {
|
|
4825
|
-
if (this.#logger) this.#logger.error(message);
|
|
4830
|
+
if (this.#logger) this.#logger.error(`${this.logPrefix}${message}`);
|
|
4831
|
+
}
|
|
4832
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4833
|
+
LogWarningMessage(message) {
|
|
4834
|
+
if (this.#logger) this.#logger.warn(`${this.logPrefix}${message}`);
|
|
4826
4835
|
}
|
|
4827
4836
|
get name() {
|
|
4828
4837
|
return this.#name;
|
|
4829
4838
|
}
|
|
4839
|
+
get reconnectTimeout() {
|
|
4840
|
+
return this.#reconnectTimeout;
|
|
4841
|
+
}
|
|
4830
4842
|
get agentManager() {
|
|
4831
4843
|
return this.#agentManager;
|
|
4832
4844
|
}
|
|
@@ -4865,6 +4877,10 @@ class SocketIoClient extends tinyEmitterExports.TinyEmitter {
|
|
|
4865
4877
|
this.#agentManager = agentManager;
|
|
4866
4878
|
return this;
|
|
4867
4879
|
}
|
|
4880
|
+
WithReconnectTimeout(reconnectTimeout) {
|
|
4881
|
+
this.#reconnectTimeout = reconnectTimeout;
|
|
4882
|
+
return this;
|
|
4883
|
+
}
|
|
4868
4884
|
SetupSocket() {
|
|
4869
4885
|
if (!this.#address) {
|
|
4870
4886
|
throw new Error(`SocketIoClientHelper:SetupSocket(): Error: [address not provided]`);
|
|
@@ -4897,9 +4913,9 @@ class SocketIoClient extends tinyEmitterExports.TinyEmitter {
|
|
|
4897
4913
|
}
|
|
4898
4914
|
this.#socket = void 0;
|
|
4899
4915
|
if (isNode) {
|
|
4900
|
-
setTimeout(() => this.#EstablishSocketConnect(),
|
|
4916
|
+
setTimeout(() => this.#EstablishSocketConnect(), this.#reconnectTimeout).unref();
|
|
4901
4917
|
} else {
|
|
4902
|
-
setTimeout(() => this.#EstablishSocketConnect(),
|
|
4918
|
+
setTimeout(() => this.#EstablishSocketConnect(), this.#reconnectTimeout);
|
|
4903
4919
|
}
|
|
4904
4920
|
return;
|
|
4905
4921
|
}
|
|
@@ -4910,7 +4926,7 @@ class SocketIoClient extends tinyEmitterExports.TinyEmitter {
|
|
|
4910
4926
|
};
|
|
4911
4927
|
if (this.#agentManager) {
|
|
4912
4928
|
if (!this.#address) {
|
|
4913
|
-
throw new Error(`
|
|
4929
|
+
throw new Error(`SocketIoClient:SetupSocket(): Error: [address not provided when using agentManager]`);
|
|
4914
4930
|
}
|
|
4915
4931
|
socketOptions.agent = this.#agentManager.GetAgent(this.#address);
|
|
4916
4932
|
}
|
|
@@ -4931,58 +4947,58 @@ class SocketIoClient extends tinyEmitterExports.TinyEmitter {
|
|
|
4931
4947
|
}
|
|
4932
4948
|
this.#socket = lookup(this.#address, socketOptions);
|
|
4933
4949
|
this.#socket.io.on("error", (err) => {
|
|
4934
|
-
this.LogErrorMessage(`
|
|
4950
|
+
this.LogErrorMessage(`socketDetail.socket.io.on('error'): [${err}] Address: [${this.#address}]`);
|
|
4935
4951
|
});
|
|
4936
4952
|
this.#socket.io.on("reconnect_error", (err) => {
|
|
4937
|
-
this.LogErrorMessage(`
|
|
4953
|
+
this.LogErrorMessage(`socketDetail.socket.io.on('reconnect_error'): [${err}] Address: [${this.#address}]`);
|
|
4938
4954
|
});
|
|
4939
4955
|
this.#socket.on("connect_error", (err) => {
|
|
4940
|
-
this.LogErrorMessage(`
|
|
4956
|
+
this.LogErrorMessage(`socketDetail.socket.on('connect_error'): [${err}] Address: [${this.#address}]`);
|
|
4941
4957
|
});
|
|
4942
4958
|
this.#socket.io.on("reconnect", (attempt) => {
|
|
4943
|
-
this.LogErrorMessage(`
|
|
4959
|
+
this.LogErrorMessage(`socketDetail.socket.io.on('reconnect'): Number: [${attempt}] Address: [${this.#address}]`);
|
|
4944
4960
|
});
|
|
4945
4961
|
this.#socket.on("connect", () => {
|
|
4946
4962
|
if (this.#socket) {
|
|
4947
|
-
this.LogDebugMessage(`
|
|
4963
|
+
this.LogDebugMessage(`Socket: [${this.#socket.id}]: connected, Address: [${this.#address}]`);
|
|
4948
4964
|
setTimeout(() => {
|
|
4949
4965
|
this.ConnectCallBack(this.#socket);
|
|
4950
4966
|
}, 0);
|
|
4951
4967
|
this.SocketEventsCallBack(this.#socket);
|
|
4952
4968
|
} else {
|
|
4953
|
-
const errorMessage = "
|
|
4969
|
+
const errorMessage = "Could not get socket object from socket.io, Address: [${socketDetail.address}]";
|
|
4954
4970
|
this.LogErrorMessage(errorMessage);
|
|
4955
4971
|
this.ErrorCallBack(new Error(errorMessage));
|
|
4956
4972
|
}
|
|
4957
4973
|
});
|
|
4958
4974
|
this.#socket.on("disconnect", (reason) => {
|
|
4959
|
-
this.LogDebugMessage("
|
|
4975
|
+
this.LogDebugMessage("socket disconnect: " + reason);
|
|
4960
4976
|
switch (reason) {
|
|
4961
4977
|
case "io server disconnect":
|
|
4962
4978
|
{
|
|
4963
|
-
this.LogDebugMessage("
|
|
4964
|
-
this.LogDebugMessage("
|
|
4979
|
+
this.LogDebugMessage("The server disconnected using disconnectSockets, i.e. normal safe shutdown from explicit disconnection by the server.");
|
|
4980
|
+
this.LogDebugMessage("The connection will be re-established when the server becomes available.");
|
|
4965
4981
|
this.#socket = void 0;
|
|
4966
4982
|
if (isNode) {
|
|
4967
4983
|
if (this.#agentManager) {
|
|
4968
4984
|
this.#agentManager.ResetAgent();
|
|
4969
4985
|
}
|
|
4970
|
-
setTimeout(() => this.#EstablishSocketConnect(),
|
|
4986
|
+
setTimeout(() => this.#EstablishSocketConnect(), this.#reconnectTimeout).unref();
|
|
4971
4987
|
} else {
|
|
4972
|
-
setTimeout(() => this.#EstablishSocketConnect(),
|
|
4988
|
+
setTimeout(() => this.#EstablishSocketConnect(), this.#reconnectTimeout);
|
|
4973
4989
|
}
|
|
4974
4990
|
}
|
|
4975
4991
|
break;
|
|
4976
4992
|
case "io client disconnect":
|
|
4977
|
-
this.LogDebugMessage("
|
|
4978
|
-
this.LogDebugMessage("
|
|
4993
|
+
this.LogDebugMessage("The client disconnected using disconnectSockets, i.e. normal safe disconnection from explicit disconnection by the client.");
|
|
4994
|
+
this.LogDebugMessage("The connection will not be re-established automatically.");
|
|
4979
4995
|
break;
|
|
4980
4996
|
case "transport close":
|
|
4981
4997
|
case "ping timeout":
|
|
4982
4998
|
case "transport error":
|
|
4983
4999
|
{
|
|
4984
|
-
this.LogDebugMessage(`
|
|
4985
|
-
this.LogDebugMessage("
|
|
5000
|
+
this.LogDebugMessage(`Server unexpectedly disconnected. Reason: [${reason}]`);
|
|
5001
|
+
this.LogDebugMessage("The connection will be re-established when the server becomes available.");
|
|
4986
5002
|
if (this.#socket) {
|
|
4987
5003
|
this.#socket.disconnect();
|
|
4988
5004
|
}
|
|
@@ -4991,9 +5007,9 @@ class SocketIoClient extends tinyEmitterExports.TinyEmitter {
|
|
|
4991
5007
|
if (this.#agentManager) {
|
|
4992
5008
|
this.#agentManager?.ResetAgent();
|
|
4993
5009
|
}
|
|
4994
|
-
setTimeout(() => this.#EstablishSocketConnect(),
|
|
5010
|
+
setTimeout(() => this.#EstablishSocketConnect(), this.#reconnectTimeout).unref();
|
|
4995
5011
|
} else {
|
|
4996
|
-
setTimeout(() => this.#EstablishSocketConnect(),
|
|
5012
|
+
setTimeout(() => this.#EstablishSocketConnect(), this.#reconnectTimeout);
|
|
4997
5013
|
}
|
|
4998
5014
|
}
|
|
4999
5015
|
break;
|