Establishes a Server-Sent Events (SSE) connection to receive real-time updates for a specific lobby.
Event Types:
connected
- Initial event with current lobby statelobby:updated
- Fired when lobby properties change (players join/leave, status updates, game server changes)lobby:deleted
- Fired when the lobby is deleted (connection will close)Requirements:
Example Usage:
const eventSource = new EventSource(
'/lobbies-sse/{lobbyId}/events?player-id={playerId}&lobby-config={configName}',
{ headers: { 'x-api-key': 'your-api-key' } }
);
eventSource.addEventListener('lobby:updated', (event) => {
const lobby = JSON.parse(event.data);
console.log('Lobby updated:', lobby);
});
Unique identifier of the lobby to subscribe to
"123e4567-e89b-12d3-a456-426614174000"
ID of the player subscribing (must be a member of the lobby)
"player123"
Name of the lobby configuration (must match an enabled config in your project)
"default-lobby"
SSE stream established successfully
The response is of type string
.
"event: connected\ndata: {\"message\":\"Successfully connected to lobby SSE\",\"lobby\":{}}\n\n"