hub location mercure adjustment
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
831603e04e
commit
aa56617e50
@@ -27,7 +27,7 @@ final class MercurePublishCommand extends Command
|
|||||||
protected function configure(): void
|
protected function configure(): void
|
||||||
{
|
{
|
||||||
$this
|
$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('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('data', null, InputOption::VALUE_REQUIRED, 'JSON payload to send', '{"message":"Hello from Mercure!"}')
|
||||||
->addOption('private', null, InputOption::VALUE_NONE, 'Mark the update as private');
|
->addOption('private', null, InputOption::VALUE_NONE, 'Mark the update as private');
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
use Symfony\Component\Mercure\HubInterface;
|
use Symfony\Component\Mercure\HubInterface;
|
||||||
use Symfony\Component\Mercure\Update;
|
use Symfony\Component\Mercure\Update;
|
||||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
|
||||||
|
|
||||||
final class GameDashboardService
|
final class GameDashboardService
|
||||||
{
|
{
|
||||||
@@ -26,8 +25,6 @@ final class GameDashboardService
|
|||||||
private readonly SessionRepository $sessionRepository,
|
private readonly SessionRepository $sessionRepository,
|
||||||
private readonly EntityManagerInterface $entityManager,
|
private readonly EntityManagerInterface $entityManager,
|
||||||
private readonly HubInterface $hub,
|
private readonly HubInterface $hub,
|
||||||
#[Autowire('%env(MERCURE_TOPIC_BASE)%')]
|
|
||||||
private readonly string $mercureTopicBase,
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,7 +327,7 @@ final class GameDashboardService
|
|||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
||||||
try {
|
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])));
|
$this->hub->publish(new Update($topic, json_encode(['type' => 'player_ready', 'player' => $player->getScreen(), 'ready' => !$setting])));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// Mercure might be down, but we don't want to crash the game
|
// Mercure might be down, but we don't want to crash the game
|
||||||
@@ -382,7 +379,7 @@ final class GameDashboardService
|
|||||||
if ($anyReset) {
|
if ($anyReset) {
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
try {
|
try {
|
||||||
$topic = $this->mercureTopicBase . '/game/hub-' . $session->getId();
|
$topic = '/game/hub/' . $session->getId();
|
||||||
$this->hub->publish(new Update($topic, json_encode(['type' => 'player_ready'])));
|
$this->hub->publish(new Update($topic, json_encode(['type' => 'player_ready'])));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// Mercure might be down
|
// Mercure might be down
|
||||||
@@ -416,7 +413,7 @@ final class GameDashboardService
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$topic = $this->mercureTopicBase . '/game/hub-' . $session->getId();
|
$topic = '/game/hub/' . $session->getId();
|
||||||
$this->hub->publish(new Update($topic, json_encode(['type' => 'all_ready'])));
|
$this->hub->publish(new Update($topic, json_encode(['type' => 'all_ready'])));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// Mercure might be down, but we don't want to crash the game
|
// Mercure might be down, but we don't want to crash the game
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||||||
use Symfony\Bundle\SecurityBundle\Security;
|
use Symfony\Bundle\SecurityBundle\Security;
|
||||||
use Symfony\Component\Mercure\HubInterface;
|
use Symfony\Component\Mercure\HubInterface;
|
||||||
use Symfony\Component\Mercure\Update;
|
use Symfony\Component\Mercure\Update;
|
||||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
|
||||||
|
|
||||||
class GameResponseService
|
class GameResponseService
|
||||||
{
|
{
|
||||||
@@ -23,8 +22,6 @@ class GameResponseService
|
|||||||
private HubInterface $hub,
|
private HubInterface $hub,
|
||||||
private EntityManagerInterface $entityManager,
|
private EntityManagerInterface $entityManager,
|
||||||
private string $projectDir,
|
private string $projectDir,
|
||||||
#[Autowire('%env(MERCURE_TOPIC_BASE)%')]
|
|
||||||
private string $mercureTopicBase,
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,7 +333,7 @@ class GameResponseService
|
|||||||
if(is_null($activeGame))
|
if(is_null($activeGame))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$topic = $this->mercureTopicBase . '/game/hub-' . $activeGame;
|
$topic = '/game/hub/' . $activeGame;
|
||||||
try {
|
try {
|
||||||
$this->hub->publish(new Update($topic, json_encode([$sendTo, $message])));
|
$this->hub->publish(new Update($topic, json_encode([$sendTo, $message])));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@@ -382,7 +379,7 @@ class GameResponseService
|
|||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
||||||
// Notify the player that their codes have changed
|
// 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.";
|
$notification = "Security Alert: One of your verify codes was shared and has been regenerated.";
|
||||||
// We send it only to this player (screen)
|
// We send it only to this player (screen)
|
||||||
try {
|
try {
|
||||||
@@ -673,7 +670,7 @@ class GameResponseService
|
|||||||
$this->entityManager->persist($everyoneVerifiedSetting);
|
$this->entityManager->persist($everyoneVerifiedSetting);
|
||||||
$this->entityManager->flush();
|
$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.";
|
$message = "Mainframe Help Modus: Agents Doyle, Vega and Lennox rapports have been updated with coded messages.";
|
||||||
try {
|
try {
|
||||||
$this->hub->publish(new Update($topic, json_encode([0, $message])));
|
$this->hub->publish(new Update($topic, json_encode([0, $message])));
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<div id="game-container">
|
<div id="game-container">
|
||||||
<div id="mercure-config"
|
<div id="mercure-config"
|
||||||
data-mercure-public-url="{{ mercure_public_url|e('html_attr') }}"
|
data-mercure-public-url="{{ mercure_public_url|e('html_attr') }}"
|
||||||
data-topic="{{ (mercure_topic_base ~ '/game/hub-' ~ session.id)|e('html_attr') }}"
|
data-topic="/game/hub/{{ session.id|e('html_attr') }}"
|
||||||
data-api-ping-url="{{ path('game_api_ping')|e('html_attr') }}"
|
data-api-ping-url="{{ path('game_api_ping')|e('html_attr') }}"
|
||||||
data-api-echo-url="{{ path('game_api_message')|e('html_attr') }}"
|
data-api-echo-url="{{ path('game_api_message')|e('html_attr') }}"
|
||||||
data-api-check-finished-url="{{ path('game_api_check_finished', {session: session.id})|e('html_attr') }}"
|
data-api-check-finished-url="{{ path('game_api_check_finished', {session: session.id})|e('html_attr') }}"
|
||||||
|
|||||||
@@ -80,7 +80,7 @@
|
|||||||
|
|
||||||
<div id="mercure-config"
|
<div id="mercure-config"
|
||||||
data-mercure-public-url="{{ mercure_public_url|e('html_attr') }}"
|
data-mercure-public-url="{{ mercure_public_url|e('html_attr') }}"
|
||||||
data-topic="{{ (mercure_topic_base ~ '/game/hub-' ~ session.id)|e('html_attr') }}"
|
data-topic="/game/hub/{{ session.id|e('html_attr') }}"
|
||||||
data-ready-at="{{ readyAt|e('html_attr') }}"
|
data-ready-at="{{ readyAt|e('html_attr') }}"
|
||||||
style="display:none">
|
style="display:none">
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user