Route every Mercure publish through an event, log pushes per-player
Every $hub->publish() call site (chat, hints, security alerts, virus alerts, game_finished, and the pre-game lobby events) now dispatches a PushMercureMessageEvent instead of publishing directly. Two listeners handle it: PublishMercureMessageListener does the actual Mercure publish exactly as before (same wire format, no client changes needed), and LogMercureMessageListener appends it to the activity log of whichever player(s) it was actually delivered to. A private /chat to one agent only gets logged for that agent, never broadcast into everyone's transcript - the event carries an explicit targetScreen (null = everyone) rather than leaving listeners to guess from the payload shape. The per-player log format moved from flat text to JSON Lines (one timestamped, structured entry per line) via a new shared SessionActivityLogger service, since a flat string can't carry an event's type or exact payload - both needed for a future feature to replay a player's full session history, not just their own commands, on page reload. The admin session log viewer now parses and formats these entries back into readable lines. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,7 +16,7 @@ use App\Tech\Entity\User;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use App\Game\Repository\GameRepository;
|
||||
use App\Game\Repository\SessionRepository;
|
||||
use Symfony\Component\Mercure\HubInterface;
|
||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class GameDashboardServiceTest extends TestCase
|
||||
@@ -25,7 +25,7 @@ class GameDashboardServiceTest extends TestCase
|
||||
private $gameRepository;
|
||||
private $sessionRepository;
|
||||
private $lobbyMessageRepository;
|
||||
private $hub;
|
||||
private $eventDispatcher;
|
||||
private $service;
|
||||
|
||||
protected function setUp(): void
|
||||
@@ -34,14 +34,14 @@ class GameDashboardServiceTest extends TestCase
|
||||
$this->gameRepository = $this->createMock(GameRepository::class);
|
||||
$this->sessionRepository = $this->createMock(SessionRepository::class);
|
||||
$this->lobbyMessageRepository = $this->createMock(LobbyMessageRepository::class);
|
||||
$this->hub = $this->createMock(HubInterface::class);
|
||||
$this->eventDispatcher = $this->createMock(EventDispatcherInterface::class);
|
||||
|
||||
$this->service = new GameDashboardService(
|
||||
$this->gameRepository,
|
||||
$this->sessionRepository,
|
||||
$this->lobbyMessageRepository,
|
||||
$this->entityManager,
|
||||
$this->hub,
|
||||
$this->eventDispatcher,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -316,8 +316,9 @@ class GameDashboardServiceTest extends TestCase
|
||||
$this->entityManager->expects($this->atLeastOnce())
|
||||
->method('flush');
|
||||
|
||||
$this->hub->expects($this->once())
|
||||
->method('publish');
|
||||
$this->eventDispatcher->expects($this->once())
|
||||
->method('dispatch')
|
||||
->willReturnArgument(0);
|
||||
|
||||
$this->service->checkAllPlayersReady($session);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user