@marianmeres/webrtc 1.3.0 → 1.3.1

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.
@@ -792,13 +792,20 @@ export class WebRtcManager {
792
792
  const state = this.#pc.connectionState;
793
793
  this.#logDebug("Connection state changed:", state);
794
794
  if (state === "connected") {
795
- // Connection successful - reset reconnect attempts and clear any pending timeout
796
- this.#reconnectAttempts = 0;
797
- if (this.#fullReconnectTimeoutTimer !== null) {
798
- clearTimeout(this.#fullReconnectTimeoutTimer);
799
- this.#fullReconnectTimeoutTimer = null;
795
+ // Only dispatch if in CONNECTING state (FSM can handle CONNECTED event)
796
+ // This guards against late connection success after user has disconnected
797
+ if (this.state === WebRtcState.CONNECTING) {
798
+ // Connection successful - reset reconnect attempts and clear any pending timeout
799
+ this.#reconnectAttempts = 0;
800
+ if (this.#fullReconnectTimeoutTimer !== null) {
801
+ clearTimeout(this.#fullReconnectTimeoutTimer);
802
+ this.#fullReconnectTimeoutTimer = null;
803
+ }
804
+ this.#dispatch(WebRtcFsmEvent.CONNECTED);
805
+ }
806
+ else {
807
+ this.#logDebug(`Ignoring late connection success (current state: ${this.state})`);
800
808
  }
801
- this.#dispatch(WebRtcFsmEvent.CONNECTED);
802
809
  }
803
810
  else if (state === "failed") {
804
811
  // Connection failed - attempt reconnection if enabled
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/webrtc",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "type": "module",
5
5
  "main": "dist/mod.js",
6
6
  "types": "dist/mod.d.ts",
@@ -13,7 +13,7 @@
13
13
  "author": "Marian Meres",
14
14
  "license": "MIT",
15
15
  "dependencies": {
16
- "@marianmeres/fsm": "^2.11.1",
16
+ "@marianmeres/fsm": "^2.14.0",
17
17
  "@marianmeres/pubsub": "^2.4.4"
18
18
  },
19
19
  "repository": {