@antzsoft/chat-core 1.3.9 → 1.4.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/index.cjs +9 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -641,6 +641,7 @@ var _getToken = null;
|
|
|
641
641
|
var _userId;
|
|
642
642
|
var _tenantId;
|
|
643
643
|
var _config = null;
|
|
644
|
+
var _preservingSession = false;
|
|
644
645
|
function setStatus(s) {
|
|
645
646
|
_status = s;
|
|
646
647
|
_statusListeners.forEach((l) => l(s));
|
|
@@ -792,7 +793,7 @@ async function _doConnect(config, getToken) {
|
|
|
792
793
|
_socket.on("connect", () => setStatus("connected"));
|
|
793
794
|
_socket.on("disconnect", () => {
|
|
794
795
|
setStatus("disconnected");
|
|
795
|
-
clearTransitSession();
|
|
796
|
+
if (!_preservingSession) clearTransitSession();
|
|
796
797
|
});
|
|
797
798
|
_socket.on("connect_error", (err) => {
|
|
798
799
|
console.error("[AntzChat] Socket connect_error:", err?.message, err?.data);
|
|
@@ -895,7 +896,13 @@ function reconnectSocket(token, userId, tenantId) {
|
|
|
895
896
|
...tenantId && { tenantId },
|
|
896
897
|
transitSessionId: existing.sessionId
|
|
897
898
|
};
|
|
898
|
-
|
|
899
|
+
_preservingSession = true;
|
|
900
|
+
try {
|
|
901
|
+
if (_socket.connected) _socket.disconnect();
|
|
902
|
+
_socket.connect();
|
|
903
|
+
} finally {
|
|
904
|
+
_preservingSession = false;
|
|
905
|
+
}
|
|
899
906
|
return;
|
|
900
907
|
}
|
|
901
908
|
if (_getToken) {
|