Some improvements

This commit is contained in:
armel committed 2026-09-08 22:33:51 +02:00
1 parent a914bd74fe
commit 729c0be834
16 files changed
+577 -36

No files matched your search

+16 -7
View File
@@ -18,21 +18,20 @@ final class GameSnapshot implements ShouldBroadcastNow
use SerializesModels;
/**
* @param array<string, mixed> $players
* @param array<int, mixed> $entities
* @param array<int, mixed> $events
* @param array<string, mixed> $players
* @param array<int, mixed> $entities
* @param array<int, mixed> $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);
return new Channel('game.'.$this->room->id);
}
public function broadcastAs(): string
@@ -50,6 +49,16 @@ final class GameSnapshot implements ShouldBroadcastNow
'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);
}
}