From 6bfb08b21c9ed26a7cfd0cd954befc8ec71102ae Mon Sep 17 00:00:00 2001 From: Lang Date: Tue, 1 Nov 2016 11:54:38 +0100 Subject: [PATCH] renamed the acme to mineseeker && handle when the user connection has been lost --- ...istener.php => MineseekerClientEventListener.php} | 2 +- .../SeekerBundle/Resources/config/pubsub/routing.yml | 12 ++++++------ src/Mine/SeekerBundle/Resources/config/services.yml | 10 +++++----- .../Resources/public/js/mine-seeker/app.js | 10 ++++++++-- .../Rpc/{AcmeRpc.php => MineseekerRpc.php} | 6 +++--- .../Topic/{AcmeTopic.php => MineseekerTopic.php} | 6 +++--- 6 files changed, 26 insertions(+), 20 deletions(-) rename src/Mine/SeekerBundle/EventListener/{AcmeClientEventListener.php => MineseekerClientEventListener.php} (97%) rename src/Mine/SeekerBundle/Rpc/{AcmeRpc.php => MineseekerRpc.php} (96%) rename src/Mine/SeekerBundle/Topic/{AcmeTopic.php => MineseekerTopic.php} (97%) diff --git a/src/Mine/SeekerBundle/EventListener/AcmeClientEventListener.php b/src/Mine/SeekerBundle/EventListener/MineseekerClientEventListener.php similarity index 97% rename from src/Mine/SeekerBundle/EventListener/AcmeClientEventListener.php rename to src/Mine/SeekerBundle/EventListener/MineseekerClientEventListener.php index fc82ae1..4f74ab2 100644 --- a/src/Mine/SeekerBundle/EventListener/AcmeClientEventListener.php +++ b/src/Mine/SeekerBundle/EventListener/MineseekerClientEventListener.php @@ -7,7 +7,7 @@ use Gos\Bundle\WebSocketBundle\Event\ClientErrorEvent; use Gos\Bundle\WebSocketBundle\Event\ServerEvent; use Gos\Bundle\WebSocketBundle\Event\ClientRejectedEvent; -class AcmeClientEventListener +class MineseekerClientEventListener { /** * Called whenever a client connects diff --git a/src/Mine/SeekerBundle/Resources/config/pubsub/routing.yml b/src/Mine/SeekerBundle/Resources/config/pubsub/routing.yml index 09b39b7..0ffe177 100644 --- a/src/Mine/SeekerBundle/Resources/config/pubsub/routing.yml +++ b/src/Mine/SeekerBundle/Resources/config/pubsub/routing.yml @@ -1,17 +1,17 @@ # Topic Configuration -acme_topic: - channel: acme/channel/{game} +mineseeker_topic: + channel: mineseeker/channel/{game} handler: - callback: 'acme.topic' #related to the getName() of your topic + callback: 'mineseeker.topic' #related to the getName() of your topic # requirements: # method: # path: '[a-z1-9A-Z]+' # Remote Procedure Call Configuration -acme_rpc: - channel: sample/{method} +mineseeker_rpc: + channel: mineseeker-rpc/{method} handler: - callback: 'acme.rpc' #related to the getName() or your RPC service + callback: 'mineseeker.rpc' #related to the getName() or your RPC service requirements: method: path: "[a-z_]+" diff --git a/src/Mine/SeekerBundle/Resources/config/services.yml b/src/Mine/SeekerBundle/Resources/config/services.yml index 58fb972..f1aaeb2 100644 --- a/src/Mine/SeekerBundle/Resources/config/services.yml +++ b/src/Mine/SeekerBundle/Resources/config/services.yml @@ -26,8 +26,8 @@ services: arguments: - "@doctrine_cache.providers.doctrine.orm.default_result_cache" - acme_hello.topic_sample_service: - class: Mine\SeekerBundle\Topic\AcmeTopic + mineseeker.topic_sample_service: + class: Mine\SeekerBundle\Topic\MineseekerTopic tags: - { name: gos_web_socket.topic } arguments: @@ -35,15 +35,15 @@ services: doctrine: '@doctrine.orm.entity_manager' requestStack: '@request_stack' - acme_hello.rpc_sample_service: - class: Mine\SeekerBundle\Rpc\AcmeRpc + mineseeker.rpc_sample_service: + class: Mine\SeekerBundle\Rpc\MineseekerRpc tags: - { name: gos_web_socket.rpc } arguments: doctrine: '@doctrine.orm.entity_manager' gos_web_socket_server.client_event.listener: - class: Mine\SeekerBundle\EventListener\AcmeClientEventListener + class: Mine\SeekerBundle\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 } diff --git a/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/app.js b/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/app.js index 1274539..3adec22 100644 --- a/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/app.js +++ b/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/app.js @@ -7,7 +7,7 @@ class MineSeeker extends React.Component { super(props); var gameAssoc = props.gameId !== '' ? props.gameId : this.makeGameAssoc(50); - var channel = "acme/channel/" + gameAssoc; + var channel = "mineseeker/channel/" + gameAssoc; this.state = { gameInherited: props.gameId !== '', @@ -50,7 +50,7 @@ class MineSeeker extends React.Component { */ session .call( - this.state.gameInherited ? "sample/connectGame" : "sample/startGame", + this.state.gameInherited ? "mineseeker-rpc/connectGame" : "mineseeker-rpc/startGame", this.state.gameInherited ? this.state.gameAssoc : [Base64.encode(JSON.stringify(gridClient)), this.state.gameAssoc] ) .then( @@ -115,6 +115,12 @@ class MineSeeker extends React.Component { }); } else { console.info(payload.msg); + + this.refs.gridControl.setState({ + overlay: true, + overlayTitle: "The connection has been lost...", + overlaySubTitle: "Please, restart the game!" + }); } } } diff --git a/src/Mine/SeekerBundle/Rpc/AcmeRpc.php b/src/Mine/SeekerBundle/Rpc/MineseekerRpc.php similarity index 96% rename from src/Mine/SeekerBundle/Rpc/AcmeRpc.php rename to src/Mine/SeekerBundle/Rpc/MineseekerRpc.php index 015a050..71d2104 100644 --- a/src/Mine/SeekerBundle/Rpc/AcmeRpc.php +++ b/src/Mine/SeekerBundle/Rpc/MineseekerRpc.php @@ -11,7 +11,7 @@ use Ratchet\ConnectionInterface; use Gos\Bundle\WebSocketBundle\RPC\RpcInterface; use Gos\Bundle\WebSocketBundle\Router\WampRequest; -class AcmeRpc implements RpcInterface +class MineseekerRpc implements RpcInterface { /** * @var EntityManager @@ -21,7 +21,7 @@ class AcmeRpc implements RpcInterface protected $grid; /** - * AcmeRpc constructor. + * MineseekerRpc constructor. * @param EntityManager $entityManager */ public function __construct(EntityManager $entityManager) @@ -36,7 +36,7 @@ class AcmeRpc implements RpcInterface */ public function getName() { - return 'acme.rpc'; + return 'mineseeker.rpc'; } /** diff --git a/src/Mine/SeekerBundle/Topic/AcmeTopic.php b/src/Mine/SeekerBundle/Topic/MineseekerTopic.php similarity index 97% rename from src/Mine/SeekerBundle/Topic/AcmeTopic.php rename to src/Mine/SeekerBundle/Topic/MineseekerTopic.php index 3ff5edc..fb834f4 100644 --- a/src/Mine/SeekerBundle/Topic/AcmeTopic.php +++ b/src/Mine/SeekerBundle/Topic/MineseekerTopic.php @@ -12,7 +12,7 @@ use Ratchet\ConnectionInterface; use Ratchet\Wamp\Topic; use Symfony\Component\HttpFoundation\RequestStack; -class AcmeTopic implements TopicInterface +class MineseekerTopic implements TopicInterface { /** @var ClientManipulatorInterface */ protected $clientManipulator; @@ -24,7 +24,7 @@ class AcmeTopic implements TopicInterface protected $requestStack; /** - * AcmeTopic constructor. + * MineseekerTopic constructor. * * @param $clientManipulator ClientManipulatorInterface * @param EntityManager $entityManager @@ -114,7 +114,7 @@ class AcmeTopic implements TopicInterface */ public function getName() { - return 'acme.topic'; + return 'mineseeker.topic'; } private function saveUserToDb($topic, $userName, $user, $count)