diff --git a/src/Command/MercurePublishCommand.php b/src/Command/MercurePublishCommand.php index 400062b..ba7408e 100644 --- a/src/Command/MercurePublishCommand.php +++ b/src/Command/MercurePublishCommand.php @@ -27,7 +27,7 @@ final class MercurePublishCommand extends Command protected function configure(): void { $this - ->addArgument('topic', InputArgument::OPTIONAL, 'Topic URL to publish to', $_ENV['MERCURE_TOPIC_BASE'] . '/game/hub') + ->addArgument('topic', InputArgument::OPTIONAL, 'Topic URL to publish to', '/game/hub/test') ->addOption('type', null, InputOption::VALUE_REQUIRED, 'Update type (for clients to filter)', 'game.event') ->addOption('data', null, InputOption::VALUE_REQUIRED, 'JSON payload to send', '{"message":"Hello from Mercure!"}') ->addOption('private', null, InputOption::VALUE_NONE, 'Mark the update as private'); diff --git a/src/Game/Service/GameDashboardService.php b/src/Game/Service/GameDashboardService.php index 0a7fe19..76de3de 100644 --- a/src/Game/Service/GameDashboardService.php +++ b/src/Game/Service/GameDashboardService.php @@ -17,7 +17,6 @@ use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Mercure\HubInterface; use Symfony\Component\Mercure\Update; -use Symfony\Component\DependencyInjection\Attribute\Autowire; final class GameDashboardService { @@ -26,8 +25,6 @@ final class GameDashboardService private readonly SessionRepository $sessionRepository, private readonly EntityManagerInterface $entityManager, private readonly HubInterface $hub, - #[Autowire('%env(MERCURE_TOPIC_BASE)%')] - private readonly string $mercureTopicBase, ) { } @@ -330,7 +327,7 @@ final class GameDashboardService $this->entityManager->flush(); try { - $topic = $this->mercureTopicBase . '/game/hub-' . $session->getId(); + $topic = '/game/hub/' . $session->getId(); $this->hub->publish(new Update($topic, json_encode(['type' => 'player_ready', 'player' => $player->getScreen(), 'ready' => !$setting]))); } catch (\Exception $e) { // Mercure might be down, but we don't want to crash the game @@ -382,7 +379,7 @@ final class GameDashboardService if ($anyReset) { $this->entityManager->flush(); try { - $topic = $this->mercureTopicBase . '/game/hub-' . $session->getId(); + $topic = '/game/hub/' . $session->getId(); $this->hub->publish(new Update($topic, json_encode(['type' => 'player_ready']))); } catch (\Exception $e) { // Mercure might be down @@ -416,7 +413,7 @@ final class GameDashboardService } try { - $topic = $this->mercureTopicBase . '/game/hub-' . $session->getId(); + $topic = '/game/hub/' . $session->getId(); $this->hub->publish(new Update($topic, json_encode(['type' => 'all_ready']))); } catch (\Exception $e) { // Mercure might be down, but we don't want to crash the game diff --git a/src/Game/Service/GameResponseService.php b/src/Game/Service/GameResponseService.php index 0e1a221..9c0d0f6 100644 --- a/src/Game/Service/GameResponseService.php +++ b/src/Game/Service/GameResponseService.php @@ -12,7 +12,6 @@ use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\Mercure\HubInterface; use Symfony\Component\Mercure\Update; -use Symfony\Component\DependencyInjection\Attribute\Autowire; class GameResponseService { @@ -23,8 +22,6 @@ class GameResponseService private HubInterface $hub, private EntityManagerInterface $entityManager, private string $projectDir, - #[Autowire('%env(MERCURE_TOPIC_BASE)%')] - private string $mercureTopicBase, ) { } @@ -336,7 +333,7 @@ class GameResponseService if(is_null($activeGame)) return false; - $topic = $this->mercureTopicBase . '/game/hub-' . $activeGame; + $topic = '/game/hub/' . $activeGame; try { $this->hub->publish(new Update($topic, json_encode([$sendTo, $message]))); } catch (\Exception $e) { @@ -382,7 +379,7 @@ class GameResponseService $this->entityManager->flush(); // Notify the player that their codes have changed - $topic = $this->mercureTopicBase . '/game/hub-' . $session->getId(); + $topic = '/game/hub/' . $session->getId(); $notification = "Security Alert: One of your verify codes was shared and has been regenerated."; // We send it only to this player (screen) try { @@ -673,7 +670,7 @@ class GameResponseService $this->entityManager->persist($everyoneVerifiedSetting); $this->entityManager->flush(); - $topic = $this->mercureTopicBase . '/game/hub-' . $session->getId(); + $topic = '/game/hub/' . $session->getId(); $message = "Mainframe Help Modus: Agents Doyle, Vega and Lennox rapports have been updated with coded messages."; try { $this->hub->publish(new Update($topic, json_encode([0, $message]))); diff --git a/templates/game/index.html.twig b/templates/game/index.html.twig index 15a6ee9..4b2b427 100644 --- a/templates/game/index.html.twig +++ b/templates/game/index.html.twig @@ -15,7 +15,7 @@