-
Notifications
You must be signed in to change notification settings - Fork 99
Open
Description
I’m currently implementing an SSE (Server-Sent Events) workflow using the HTTP library, and I’m trying to design a pattern for handling many users subscribing to a single SSE endpoint, while still being able to treat each subscriber individually.
What I want to achieve
I want to expose one SSE endpoint, for example:
/tournaments/updates
But this single endpoint should be able to:
- Accept multiple users simultaneously
- Identify each user separately
- Maintain per-user state or metadata (e.g., what tournament they are interested in)
- Only send each user the events relevant to their context
Example use-case
Imagine a game platform where many users subscribe to the tournament updates SSE.
There can be hundreds of tournaments, but I don’t want to create an SSE endpoint per tournament.
Instead:
- All users connect to one SSE endpoint
- Each user sends (for example) a query parameter or header such as
?tournament_id=abc123 - The server receives the SSE connection
- The SSE handler stores some per-user info (user ID, tournament ID, permissions, etc.)
- The library should allow me to route or target updates to the correct subscriber(s)
My question
What is the recommended way to structure this with your SSE implementation?
- How do I keep per-connection state inside an SSE endpoint?
- How do I distinguish users and send each of them only the events they subscribed to?
- Is there a canonical pattern for fan-out to multiple users from a single endpoint using this library?
Any guidance or example code would help a lot.
Thanks so much
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels