Просмотр исходного кода

Cancel pending cast auto-reconnect on new session

When opening a new cast session, clear any pending auto-reconnect timers and reset reconnect counters/pending codes to prevent reconnecting to the old room. Applied to Movie (src/web/Movie/index.html), Musicify (src/web/Musicify/musicify.js) and Photo (src/web/Photo/photo.js).
Toby Chui 1 неделя назад
Родитель
Сommit
9e29a5e1be
3 измененных файлов с 10 добавлено и 0 удалено
  1. 3 0
      src/web/Movie/index.html
  2. 4 0
      src/web/Musicify/musicify.js
  3. 3 0
      src/web/Photo/photo.js

+ 3 - 0
src/web/Movie/index.html

@@ -1367,6 +1367,9 @@ function connectCast() {
 
             if (castWs) { castWs.onclose = null; castWs.close(); castWs = null; }
             clearInterval(castPingTimer); clearInterval(castWatchTimer);
+            // Cancel any pending auto-reconnect to the old room — user is opening a new session
+            clearTimeout(castReconnectTimer); castReconnectTimer = null;
+            castReconnectCount = 0; castPendingCode = null;
 
             // Signal other apps (Musicify, Photo) to yield the cast room
             try { new BroadcastChannel('arozcast').postMessage({ type: 'arozcast.takeover' }); } catch(e) {}

+ 4 - 0
src/web/Musicify/musicify.js

@@ -1296,6 +1296,10 @@ function musicifyApp() {
 
         _castOpen(code) {
             var self = this;
+            // Cancel any pending auto-reconnect to the old room — user is opening a new session
+            clearTimeout(this._castReconnectTimer); this._castReconnectTimer = null;
+            this._castReconnectCount = 0; this._castPendingCode = null;
+
             var wsUrl = new URL(ao_root + 'api/arozcast/ws?code=' + code, window.location.href);
             wsUrl.protocol = (location.protocol === 'https:') ? 'wss:' : 'ws:';
 

+ 3 - 0
src/web/Photo/photo.js

@@ -935,6 +935,9 @@ function connectPhotoCast() {
             }
             clearInterval(_photoCastPingTimer);
             clearInterval(_photoCastWatchTimer);
+            // Cancel any pending auto-reconnect to the old room — user is opening a new session
+            clearTimeout(_photoCastReconnectTimer); _photoCastReconnectTimer = null;
+            _photoCastReconnectCount = 0; _photoCastPendingCode = null;
 
             // Signal other apps (e.g. Musicify) to yield the cast session
             try { new BroadcastChannel('arozcast').postMessage({ type: 'arozcast.takeover' }); } catch(e) {}