SSE Events
Draft Documentation - This section is currently under review and may be subject to changes.
SSE Event Types
This section documents the various event types that can be delivered via Server-Sent Events (SSE). Each event type has a specific structure and purpose.
Overview
SSE events are published to Redis using the channel pattern SSE::{brand_id}::{player_id} and delivered in real-time to connected clients. All events follow a consistent base structure with event-specific data payloads.
Event Structure
All SSE events (excluding system events like “connected” and “keepalive”) follow this structure:
{
"brand_id": 1001,
"player_id": 12345,
"event_type": "notification",
"event_data": {
// Event-specific payload
}
}Base Fields
| Field | Type | Description |
|---|---|---|
| brand_id | int | The casino brand identifier. |
| player_id | int | The player identifier. |
| event_type | string | The type of event (e.g., “notification”). |
| event_data | object | Event-specific data (structure varies by type). |
System Events
These events are sent by the SSE system itself for connection management:
Connected Event
Sent immediately upon successful SSE connection establishment.
{
"type": "connected",
"timestamp": "2025-10-22T14:30:45Z"
}Keep-alive Event
Sent every 15 seconds to maintain the connection.
: keepalive 2025-10-22 14:30:45
data: {"type":"keepalive","timestamp":"2025-10-22 14:30:45"}Error Event
Sent when an error occurs during the SSE connection.
{
"type": "error",
"message": "Failed to subscribe to events"
}Application Events
These events are published by various services in the platform:
Currently Available Events
- notification - In-app notification events for bonuses, promotions, and account updates
- gamification_balance_update - Real-time gamification coin balance updates
Event Publishing
Events are published by backend services using the SSE service from go_casino_kit:
sseService.Publish(ctx, brandID, playerID, eventType, eventData)This publishes to the Redis channel SSE::{brandID}::{playerID}, which the gateway listens to and forwards to connected clients.
Future Event Types
The SSE system is designed to be extensible. Future event types may include:
- wallet_balance_update - Real-time wallet balance changes
- game_result - Game round results and wins
- tournament_update - Tournament status and leaderboard changes
- message - Direct messages from support or system
- promotion_trigger - Personalized promotion availability
Implementation Notes
- All events are delivered in real-time (typically < 100ms latency)
- Events are not persisted - if a client is disconnected, events during that time are lost
- Each event is delivered as a separate SSE message with
data:prefix - Events are JSON-formatted for easy parsing
- Multiple events can be sent in rapid succession (buffer size: 50 events)