@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 CHANGED
@@ -1525,6 +1525,7 @@ var _getToken = null;
1525
1525
  var _userId;
1526
1526
  var _tenantId;
1527
1527
  var _config2 = null;
1528
+ var _preservingSession = false;
1528
1529
  function setStatus(s) {
1529
1530
  _status = s;
1530
1531
  _statusListeners.forEach((l) => l(s));
@@ -1676,7 +1677,7 @@ async function _doConnect(config, getToken) {
1676
1677
  _socket.on("connect", () => setStatus("connected"));
1677
1678
  _socket.on("disconnect", () => {
1678
1679
  setStatus("disconnected");
1679
- clearTransitSession();
1680
+ if (!_preservingSession) clearTransitSession();
1680
1681
  });
1681
1682
  _socket.on("connect_error", (err) => {
1682
1683
  console.error("[AntzChat] Socket connect_error:", err?.message, err?.data);
@@ -1779,7 +1780,13 @@ function reconnectSocket(token, userId, tenantId) {
1779
1780
  ...tenantId && { tenantId },
1780
1781
  transitSessionId: existing.sessionId
1781
1782
  };
1782
- _socket.connect();
1783
+ _preservingSession = true;
1784
+ try {
1785
+ if (_socket.connected) _socket.disconnect();
1786
+ _socket.connect();
1787
+ } finally {
1788
+ _preservingSession = false;
1789
+ }
1783
1790
  return;
1784
1791
  }
1785
1792
  if (_getToken) {