Realtime (Action Cable + Trailblazer 2.1)
Dependencies
- •actioncable
- •trailblazer-operation
- •trailblazer-rails
Channels Organization (Pattern)
- •
app/channels/hosts channel classes - •One channel per domain concept (game/room)
- •Authorization happens in
subscribed - •Use
stream_forwith domain instances - •Keep channels thin and delegate logic to Operations
Messages (Pattern)
- •JSON payloads with
typeand small deltas - •Include timestamps in broadcasts
Operations Broadcasting (Pattern)
- •Broadcast inside Operations after successful state changes
- •Example:
Game::BroadcastChannel.broadcast_to(game, { type: 'player_moved', ... })
See Channels for requirements.