Private
Public Access
1
0

chg: dev: replace the legacy gos/web-socket-bundle & replace it with Mercure protocol #4

This commit is contained in:
2026-04-09 22:00:53 +02:00
parent b55c223d8a
commit 7219471a86
33 changed files with 1198 additions and 2324 deletions

View File

@@ -8,8 +8,7 @@ return [
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Gos\Bundle\PubSubRouterBundle\GosPubSubRouterBundle::class => ['all' => true],
Gos\Bundle\WebSocketBundle\GosWebSocketBundle::class => ['all' => true],
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\MercureBundle\MercureBundle::class => ['all' => true],
];

View File

@@ -1,28 +0,0 @@
#doctrine_cache:
# providers:
# redis_cache:
# redis:
# host: localhost
# port: 6379
# database: 3
# websocket_cache_client:
# type: redis
# alias: gos_web_socket.client_storage.driver.redis
gos_web_socket:
server:
host: 0.0.0.0
port: "%mineseeker.websocket%"
router:
resources:
- '%kernel.project_dir%/config/pubsub/routing.yaml'
client:
firewall: secured_area
# session_handler: "@session.handler.pdo"
# storage:
# driver: "@gos_web_socket.client_storage.driver.predis"
# ttl: 28800 #(optionally) time to live if you use redis driver
# prefix: client #(optionally) prefix if you use redis driver, create key "client:1" instead key "1"
ping:
services:
- { name: doctrine.dbal.default_connection, type: doctrine, interval: 300 }

View File

@@ -0,0 +1,8 @@
mercure:
hubs:
default:
url: '%env(MERCURE_URL)%'
public_url: '%env(MERCURE_PUBLIC_URL)%'
jwt:
secret: '%env(MERCURE_JWT_SECRET)%'
publish: '*'

View File

@@ -1,14 +0,0 @@
## Topic Configuration
mineseeker_topic:
channel: mineseeker/channel/{game}
callback: 'mineseeker.topic'
# requirements:
# method:
# path: '[a-z1-9A-Z]+'
# Remote Procedure Call Configuration
mineseeker_rpc:
channel: mineseeker-rpc/{method}
callback: 'mineseeker.rpc'
requirements:
method: "[a-zA-Z_]+"

View File

@@ -24,4 +24,30 @@ MineSeekerBundle_contact:
MineSeekerBundle_landing:
path: /landing-page
controller: App\Controller\GameController::landing
controller: App\Controller\GameController::landing
MineSeekerBundle_api_game_start:
path: /api/game/start
controller: App\Controller\MercureController::start
methods: [POST]
MineSeekerBundle_api_game_connect:
path: /api/game/connect/{gameAssoc}
controller: App\Controller\MercureController::connect
methods: [GET]
MineSeekerBundle_api_game_join:
path: /api/game/join/{gameAssoc}
controller: App\Controller\MercureController::join
methods: [POST]
MineSeekerBundle_api_game_step:
path: /api/game/step/{gameAssoc}
controller: App\Controller\MercureController::step
methods: [POST]
MineSeekerBundle_api_game_leave:
path: /api/game/leave/{gameAssoc}
controller: App\Controller\MercureController::leave
methods: [POST]

View File

@@ -3,11 +3,6 @@
parameters:
locale: 'en'
jotunheimr.version: 1.1.0-20191026
facebook.api: 320599508311862
facebook.api-secret: 18d4f48cdd274bccee2678e5eff3f557
facebook.version: 'v2.8'
facebook.scope: 'public_profile,email,user_friends'
mineseeker.websocket: 6450
services:
# default configuration for services in *this* file
@@ -16,50 +11,16 @@ services:
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
public: false # Allows optimizing the container by removing unused services; this also means
# fetching services directly from the container via $container->get() won't work.
# The best practice is to be explicit about your dependencies anyway.
# The best practice is to be explicit about your dependencies anyway.
# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App\:
resource: '../src/*'
exclude: '../src/{Command/WebsocketServerCommand.php,Entity,Migrations,Tests,Kernel.php,Periodic}'
exclude: '../src/{Entity,Migrations,Tests,Kernel.php}'
# controllers are imported separately to make sure services can be injected
# as action arguments even if you don't extend any base controller class
App\Controller\:
resource: '../src/Controller'
tags: [ 'controller.service_arguments' ]
# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
mineseeker.topic_sample_service:
class: App\Topic\MineseekerTopic
tags:
- { name: gos_web_socket.topic }
mineseeker.rpc_sample_service:
class: App\Rpc\MineseekerRpc
public: true
tags:
- { name: gos_web_socket.rpc }
# Override gos WebsocketServerCommand to avoid --profile conflict with Symfony 6.4 global option
gos_web_socket.command.websocket_server:
class: App\Command\WebsocketServerCommand
arguments:
- '@gos_web_socket.server.launcher'
- '%gos_web_socket.server.host%'
- '%gos_web_socket.server.port%'
- '@gos_web_socket.registry.server'
tags:
- { name: console.command, command: 'gos:websocket:server' }
gos_web_socket_server.client_event.listener:
class: App\EventListener\MineseekerClientEventListener
tags:
- { name: kernel.event_listener, event: 'gos_web_socket.client_connected', method: onClientConnect }
- { name: kernel.event_listener, event: 'gos_web_socket.client_disconnected', method: onClientDisconnect }
- { name: kernel.event_listener, event: 'gos_web_socket.client_error', method: onClientError }
- { name: kernel.event_listener, event: 'gos_web_socket.server_launched', method: onServerStart }
- { name: kernel.event_listener, event: 'gos_web_socket.client_rejected', method: onClientRejected }