fix: close existing SSE before opening new one (BUG-11)
Prevents duplicate SSE connections when connectSSE is called without prior disconnect. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
d47be39156
commit
0f606cc991
@@ -102,6 +102,8 @@ export function useFightPolling(fightId: Ref<string>) {
|
|||||||
onHumanChallenge?: (data: any) => void
|
onHumanChallenge?: (data: any) => void
|
||||||
onReaction?: (data: any) => void
|
onReaction?: (data: any) => void
|
||||||
}) {
|
}) {
|
||||||
|
// Close any existing SSE connection before opening a new one
|
||||||
|
disconnectSSE()
|
||||||
eventSource = new EventSource(`/api/fights/${fightId.value}/stream`)
|
eventSource = new EventSource(`/api/fights/${fightId.value}/stream`)
|
||||||
|
|
||||||
addSSEListener(eventSource, 'spectator_count', (e) => {
|
addSSEListener(eventSource, 'spectator_count', (e) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user