$players * @param array $entities * @param array $events */ public function __construct( public Room $room, public array $players, public array $entities, public array $events, ) {} public function broadcastOn(): Channel { return new Channel('game.'.$this->room->id); } public function broadcastAs(): string { return 'snapshot'; } /** @return array */ public function broadcastWith(): array { return [ 'state' => $this->room->state, 'elapsed' => round($this->room->elapsed, 2), 'seq' => $this->room->seq, 'players' => $this->players, 'entities' => $this->entities, 'events' => $this->events, 'msgCap' => $this->messageSizeCap(), ]; } /** * Largest snapshot the WebSocket layer will deliver in one frame; used by * the client debug HUD to show broadcast headroom against the Reverb cap. */ private function messageSizeCap(): int { return (int) config('reverb.apps.apps.0.max_message_size', 20_000); } }