Spaces:
Running
Running
Fix session cleanup: send endSession when stopping stream
Browse filesThe 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>
- 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;
|