Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add SSE Endpoint for Queue#337

Merged
PhlexPlexico merged 1 commit into
PhlexPlexico:2.2.0.0from
mfamahran:queue-sse-endpoint
Mar 12, 2026
Merged

Add SSE Endpoint for Queue#337
PhlexPlexico merged 1 commit into
PhlexPlexico:2.2.0.0from
mfamahran:queue-sse-endpoint

Conversation

@mfamahran

Copy link
Copy Markdown
Contributor

Summary

This PR adds real-time queue state streaming so clients can react immediately to queue membership and match creation events without polling.

  • Adds GET /queue/:slug/stream as an SSE endpoint that emits queue_state updates with:
    • latest queue snapshot
    • current users in queue
    • optional match info (id, serverId) when a match is created
  • Emits queueUpdate events on queue join and leave actions in queue route handlers.
  • Emits queueUpdate with match_created payload when queue processing creates a match (with or without a selected server).
  • Refactors repeated role detection into a shared getRequesterRole() helper in queue routes.
  • Includes players_per_team in match creation payload for queue-driven matches.

Why

The frontend queue page and live hooks need push-based updates for queue activity and match transitions. SSE + queue events provide a simple, low-latency mechanism to keep clients in sync and reduce polling complexity.

Test plan

  • Start API and connect to stream:
    • curl -N http://<api>/queue/<slug>/stream
  • Join queue from another authenticated client and verify a queue_state event is received with incremented currentPlayers.
  • Leave queue and verify a queue_state event is received with decremented currentPlayers.
  • Fill queue to trigger match creation and verify stream emits queue_state with match.id and match.serverId (or null when no server assigned).
  • Verify queue cleanup still works when last player leaves and no permission regression is introduced.
  • Confirm existing queue endpoints (GET /queue/:slug, PUT /queue/:slug) continue to behave as before.

@PhlexPlexico PhlexPlexico merged commit d41dec4 into PhlexPlexico:2.2.0.0 Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants