cduss Claude Opus 4.5 commited on
Commit
60f76d1
·
1 Parent(s): 9a831f5

Fix session cleanup: send endSession when stopping stream

Browse files

The client now notifies the server when a session ends, preventing
stale session mappings that cause connection issues after multiple
start/stop cycles.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Files changed (1) hide show
  1. index.html +7 -1
index.html CHANGED
@@ -865,9 +865,15 @@
865
  }, 2000); // Check every 2 seconds
866
  }
867
 
868
- function stopStream() {
869
  if (latencyMonitorId) clearInterval(latencyMonitorId);
870
  if (stateRefreshInterval) clearInterval(stateRefreshInterval);
 
 
 
 
 
 
871
  if (peerConnection) peerConnection.close();
872
  if (dataChannel) dataChannel.close();
873
  peerConnection = null;
 
865
  }, 2000); // Check every 2 seconds
866
  }
867
 
868
+ async function stopStream() {
869
  if (latencyMonitorId) clearInterval(latencyMonitorId);
870
  if (stateRefreshInterval) clearInterval(stateRefreshInterval);
871
+
872
+ // Notify server that session is ending
873
+ if (currentSessionId) {
874
+ await sendToServer({ type: 'endSession', sessionId: currentSessionId });
875
+ }
876
+
877
  if (peerConnection) peerConnection.close();
878
  if (dataChannel) dataChannel.close();
879
  peerConnection = null;