chg: usr: make the first working version - the stepping is broken due to the algorythm structure #4
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Application\Sonata\UserBundle\Document;
|
||||
|
||||
use Sonata\UserBundle\Document\BaseGroup as BaseGroup;
|
||||
|
||||
/**
|
||||
* This file has been generated by the SonataEasyExtendsBundle.
|
||||
*
|
||||
* @link https://sonata-project.org/easy-extends
|
||||
*
|
||||
* References:
|
||||
* @link http://www.doctrine-project.org/docs/mongodb_odm/1.0/en/reference/working-with-objects.html
|
||||
*/
|
||||
class Group extends BaseGroup
|
||||
{
|
||||
/**
|
||||
* @var int $id
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* Get id.
|
||||
*
|
||||
* @return int $id
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Application\Sonata\UserBundle\Entity;
|
||||
|
||||
use Sonata\UserBundle\Entity\BaseGroup as BaseGroup;
|
||||
|
||||
/**
|
||||
* This file has been generated by the SonataEasyExtendsBundle.
|
||||
*
|
||||
* @link https://sonata-project.org/easy-extends
|
||||
*
|
||||
* References:
|
||||
* @link http://www.doctrine-project.org/projects/orm/2.0/docs/reference/working-with-objects/en
|
||||
*/
|
||||
class Group extends BaseGroup
|
||||
{
|
||||
/**
|
||||
* @var int $id
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* Get id.
|
||||
*
|
||||
* @return int $id
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<doctrine-mongo-mapping xmlns="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping
|
||||
http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd">
|
||||
|
||||
<document name="App\Application\Sonata\UserBundle\Document\Group" collection="fos_user_group">
|
||||
|
||||
<field fieldName="id" id="true" strategy="INCREMENT" />
|
||||
|
||||
</document>
|
||||
|
||||
</doctrine-mongo-mapping>
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="App\Application\Sonata\UserBundle\Entity\Group" table="fos_user_group">
|
||||
|
||||
<id name="id" column="id" type="integer">
|
||||
<generator strategy="AUTO" />
|
||||
</id>
|
||||
|
||||
</entity>
|
||||
|
||||
</doctrine-mapping>
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<serializer>
|
||||
<!-- This file has been generated by the SonataEasyExtendsBundle: https://sonata-project.org/bundles/easy-extends -->
|
||||
<class name="App\Application\Sonata\UserBundle\Document\Group" exclusion-policy="all" xml-root-name="_group">
|
||||
<property xml-attribute-map="true" name="id" type="integer" expose="true" since-version="1.0" groups="sonata_api_read,sonata_api_write,sonata_search"/>
|
||||
</class>
|
||||
</serializer>
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<serializer>
|
||||
<!-- This file has been generated by the SonataEasyExtendsBundle: https://sonata-project.org/bundles/easy-extends -->
|
||||
<class name="App\Application\Sonata\UserBundle\Entity\Group" exclusion-policy="all" xml-root-name="_group">
|
||||
<property xml-attribute-map="true" name="id" type="integer" expose="true" since-version="1.0" groups="sonata_api_read,sonata_api_write,sonata_search"/>
|
||||
</class>
|
||||
</serializer>
|
||||
@@ -10,10 +10,11 @@
|
||||
|
||||
namespace App\EventListener;
|
||||
|
||||
use Gos\Bundle\WebSocketBundle\Event\ClientEvent;
|
||||
use Gos\Bundle\WebSocketBundle\Event\ClientConnectedEvent;
|
||||
use Gos\Bundle\WebSocketBundle\Event\ClientDisconnectedEvent;
|
||||
use Gos\Bundle\WebSocketBundle\Event\ClientErrorEvent;
|
||||
use Gos\Bundle\WebSocketBundle\Event\ServerEvent;
|
||||
use Gos\Bundle\WebSocketBundle\Event\ClientRejectedEvent;
|
||||
use Gos\Bundle\WebSocketBundle\Event\ServerLaunchedEvent;
|
||||
|
||||
/**
|
||||
* Class MineseekerClientEventListener
|
||||
@@ -23,35 +24,20 @@ use Gos\Bundle\WebSocketBundle\Event\ClientRejectedEvent;
|
||||
*/
|
||||
class MineseekerClientEventListener
|
||||
{
|
||||
/**
|
||||
* Called whenever a client connects
|
||||
*
|
||||
* @param ClientEvent $event
|
||||
*/
|
||||
public function onClientConnect(ClientEvent $event): void
|
||||
public function onClientConnect(ClientConnectedEvent $event): void
|
||||
{
|
||||
$conn = $event->getConnection();
|
||||
|
||||
echo $conn->resourceId . ' connected' . PHP_EOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever a client disconnects
|
||||
*
|
||||
* @param ClientEvent $event
|
||||
*/
|
||||
public function onClientDisconnect(ClientEvent $event): void
|
||||
public function onClientDisconnect(ClientDisconnectedEvent $event): void
|
||||
{
|
||||
$conn = $event->getConnection();
|
||||
|
||||
echo $conn->resourceId . ' disconnected' . PHP_EOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever a client errors
|
||||
*
|
||||
* @param ClientErrorEvent $event
|
||||
*/
|
||||
public function onClientError(ClientErrorEvent $event): void
|
||||
{
|
||||
$conn = $event->getConnection();
|
||||
@@ -60,26 +46,14 @@ class MineseekerClientEventListener
|
||||
echo 'connection error occurred: ' . $e->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever server start
|
||||
*
|
||||
* @param ServerEvent $event
|
||||
*/
|
||||
public function onServerStart(ServerEvent $event): void
|
||||
public function onServerStart(ServerLaunchedEvent $event): void
|
||||
{
|
||||
$event = $event->getEventLoop();
|
||||
|
||||
echo 'Server was successfully started !' . PHP_EOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever client is rejected by application
|
||||
*
|
||||
* @param ClientRejectedEvent $event
|
||||
*/
|
||||
public function onClientRejected(ClientRejectedEvent $event): void
|
||||
{
|
||||
$origin = $event->getOrigin;
|
||||
$origin = $event->getOrigin();
|
||||
|
||||
echo 'connection rejected from ' . $origin . PHP_EOL;
|
||||
}
|
||||
|
||||
@@ -3,59 +3,19 @@
|
||||
namespace App;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
|
||||
use Symfony\Component\Routing\RouteCollectionBuilder;
|
||||
|
||||
class Kernel extends BaseKernel
|
||||
{
|
||||
use MicroKernelTrait;
|
||||
|
||||
const CONFIG_EXTS = '.{php,xml,yaml,yml}';
|
||||
|
||||
public function getCacheDir()
|
||||
public function getCacheDir(): string
|
||||
{
|
||||
return $this->getProjectDir().'/var/cache/'.$this->environment;
|
||||
}
|
||||
|
||||
public function getLogDir()
|
||||
public function getLogDir(): string
|
||||
{
|
||||
return $this->getProjectDir().'/var/log';
|
||||
}
|
||||
|
||||
public function registerBundles()
|
||||
{
|
||||
$contents = require $this->getProjectDir().'/config/bundles.php';
|
||||
foreach ($contents as $class => $envs) {
|
||||
if (isset($envs['all']) || isset($envs[$this->environment])) {
|
||||
yield new $class();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader)
|
||||
{
|
||||
$container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php'));
|
||||
// Feel free to remove the "container.autowiring.strict_mode" parameter
|
||||
// if you are using symfony/dependency-injection 4.0+ as it's the default behavior
|
||||
$container->setParameter('container.autowiring.strict_mode', true);
|
||||
$container->setParameter('container.dumper.inline_class_loader', true);
|
||||
$confDir = $this->getProjectDir().'/config';
|
||||
|
||||
$loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob');
|
||||
$loader->load($confDir.'/{packages}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob');
|
||||
$loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob');
|
||||
$loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob');
|
||||
}
|
||||
|
||||
protected function configureRoutes(RouteCollectionBuilder $routes)
|
||||
{
|
||||
$confDir = $this->getProjectDir().'/config';
|
||||
|
||||
$routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob');
|
||||
$routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob');
|
||||
$routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob');
|
||||
}
|
||||
}
|
||||
}
|
||||
84
src/Migrations/2026/04/Version20260409081936.php
Normal file
84
src/Migrations/2026/04/Version20260409081936.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20260409081936 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('CREATE SEQUENCE fos_user_user_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE SEQUENCE gamer_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE SEQUENCE grid_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE SEQUENCE grid_row_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE SEQUENCE played_game_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE SEQUENCE step_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE TABLE fos_user_user (id INT NOT NULL, username VARCHAR(180) NOT NULL, username_canonical VARCHAR(180) NOT NULL, email VARCHAR(180) NOT NULL, email_canonical VARCHAR(180) NOT NULL, enabled BOOLEAN NOT NULL, salt VARCHAR(255) DEFAULT NULL, password VARCHAR(255) NOT NULL, last_login TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, confirmation_token VARCHAR(180) DEFAULT NULL, password_requested_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, roles TEXT NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('CREATE UNIQUE INDEX UNIQ_C560D76192FC23A8 ON fos_user_user (username_canonical)');
|
||||
$this->addSql('CREATE UNIQUE INDEX UNIQ_C560D761A0D96FBF ON fos_user_user (email_canonical)');
|
||||
$this->addSql('CREATE UNIQUE INDEX UNIQ_C560D761C05FB297 ON fos_user_user (confirmation_token)');
|
||||
$this->addSql('COMMENT ON COLUMN fos_user_user.roles IS \'(DC2Type:array)\'');
|
||||
$this->addSql('CREATE TABLE gamer (id INT NOT NULL, user_name VARCHAR(100) NOT NULL, ip VARCHAR(20) DEFAULT NULL, country VARCHAR(100) DEFAULT NULL, user_agent VARCHAR(255) DEFAULT NULL, conn_timestamp TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('CREATE TABLE grid (id INT NOT NULL, played_game_id INT DEFAULT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('CREATE UNIQUE INDEX UNIQ_2E20D9375AA11DBB ON grid (played_game_id)');
|
||||
$this->addSql('CREATE TABLE grid_row (id INT NOT NULL, grid INT DEFAULT NULL, grid_col JSON NOT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('CREATE INDEX IDX_6FAD08EB2E20D937 ON grid_row (grid)');
|
||||
$this->addSql('COMMENT ON COLUMN grid_row.grid_col IS \'(DC2Type:json_array)\'');
|
||||
$this->addSql('CREATE TABLE played_game (id INT NOT NULL, red_id INT DEFAULT NULL, red_anon INT DEFAULT NULL, blue_id INT DEFAULT NULL, blue_anon INT DEFAULT NULL, game_assoc VARCHAR(50) NOT NULL, red_points INT DEFAULT NULL, blue_points INT DEFAULT NULL, red_exploded_bomb BOOLEAN DEFAULT NULL, blue_exploded_bomb BOOLEAN DEFAULT NULL, resign VARCHAR(7) DEFAULT NULL, created TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, updated TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('CREATE INDEX IDX_54BE80398BBE8922 ON played_game (red_id)');
|
||||
$this->addSql('CREATE INDEX IDX_54BE8039F24372EB ON played_game (red_anon)');
|
||||
$this->addSql('CREATE INDEX IDX_54BE80395AB9393F ON played_game (blue_id)');
|
||||
$this->addSql('CREATE INDEX IDX_54BE8039C64E7C7C ON played_game (blue_anon)');
|
||||
$this->addSql('CREATE TABLE step (id INT NOT NULL, played_game_id INT DEFAULT NULL, row INT NOT NULL, col INT NOT NULL, wbomb BOOLEAN DEFAULT NULL, created TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('CREATE INDEX IDX_43B9FE3C5AA11DBB ON step (played_game_id)');
|
||||
$this->addSql('ALTER TABLE grid ADD CONSTRAINT FK_2E20D9375AA11DBB FOREIGN KEY (played_game_id) REFERENCES played_game (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE grid_row ADD CONSTRAINT FK_6FAD08EB2E20D937 FOREIGN KEY (grid) REFERENCES grid (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE played_game ADD CONSTRAINT FK_54BE80398BBE8922 FOREIGN KEY (red_id) REFERENCES fos_user_user (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE played_game ADD CONSTRAINT FK_54BE8039F24372EB FOREIGN KEY (red_anon) REFERENCES gamer (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE played_game ADD CONSTRAINT FK_54BE80395AB9393F FOREIGN KEY (blue_id) REFERENCES fos_user_user (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE played_game ADD CONSTRAINT FK_54BE8039C64E7C7C FOREIGN KEY (blue_anon) REFERENCES gamer (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE step ADD CONSTRAINT FK_43B9FE3C5AA11DBB FOREIGN KEY (played_game_id) REFERENCES played_game (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('CREATE SCHEMA public');
|
||||
$this->addSql('ALTER TABLE played_game DROP CONSTRAINT FK_54BE80398BBE8922');
|
||||
$this->addSql('ALTER TABLE played_game DROP CONSTRAINT FK_54BE80395AB9393F');
|
||||
$this->addSql('ALTER TABLE played_game DROP CONSTRAINT FK_54BE8039F24372EB');
|
||||
$this->addSql('ALTER TABLE played_game DROP CONSTRAINT FK_54BE8039C64E7C7C');
|
||||
$this->addSql('ALTER TABLE grid_row DROP CONSTRAINT FK_6FAD08EB2E20D937');
|
||||
$this->addSql('ALTER TABLE grid DROP CONSTRAINT FK_2E20D9375AA11DBB');
|
||||
$this->addSql('ALTER TABLE step DROP CONSTRAINT FK_43B9FE3C5AA11DBB');
|
||||
$this->addSql('DROP SEQUENCE fos_user_user_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE gamer_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE grid_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE grid_row_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE played_game_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE step_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE fos_user_user');
|
||||
$this->addSql('DROP TABLE gamer');
|
||||
$this->addSql('DROP TABLE grid');
|
||||
$this->addSql('DROP TABLE grid_row');
|
||||
$this->addSql('DROP TABLE played_game');
|
||||
$this->addSql('DROP TABLE step');
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ class MinePeriodic implements PeriodicInterface
|
||||
*
|
||||
* For more advanced functionality, try injecting a Topic Service to perform actions on your connections every x seconds.
|
||||
*/
|
||||
public function tick()
|
||||
public function tick(): void
|
||||
{
|
||||
$this->ping->tick();
|
||||
}
|
||||
@@ -47,7 +47,7 @@ class MinePeriodic implements PeriodicInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getTimeout()
|
||||
public function getTimeout(): int
|
||||
{
|
||||
return 300;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace App\Repository;
|
||||
|
||||
use App\Entity\Gamer;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* Class GamerRepository
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace App\Repository;
|
||||
|
||||
use App\Entity\Grid;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* Class GridRepository
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace App\Repository;
|
||||
|
||||
use App\Entity\GridRow;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* Class GridRowRepository
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace App\Repository;
|
||||
|
||||
use App\Entity\PlayedGame;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* Class PlayedGameRepository
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace App\Repository;
|
||||
|
||||
use App\Entity\Step;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* Class StepRepository
|
||||
|
||||
@@ -54,8 +54,9 @@ class RpcManager extends WebsocketManager implements RpcManagerInterface
|
||||
*/
|
||||
public function getConnectInformation($params): string
|
||||
{
|
||||
$grid = $this->getGrid($params);
|
||||
$users = null !== $grid ? $this->getUsers($params) : null;
|
||||
$gameAssoc = is_array($params) ? $params[0] : $params;
|
||||
$grid = $this->getGrid($gameAssoc);
|
||||
$users = null !== $grid ? $this->getUsers($gameAssoc) : null;
|
||||
|
||||
return base64_encode(json_encode(array(
|
||||
'grid' => $grid,
|
||||
|
||||
@@ -23,6 +23,7 @@ use Psr\Log\LoggerInterface;
|
||||
use Ratchet\ConnectionInterface;
|
||||
use Ratchet\Wamp\Topic;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
|
||||
/**
|
||||
* Class TopicManager
|
||||
@@ -74,7 +75,7 @@ class TopicManager extends WebsocketManager implements TopicManagerInterface
|
||||
{
|
||||
/** this will broadcast the message to ALL subscribers of this topic. */
|
||||
$user = $this->clientManipulator->getClient($connection);
|
||||
$userName = is_string($user) ? $user : $user->getUsername();
|
||||
$userName = $user->getUserIdentifier();
|
||||
|
||||
/** if more user wants to connect than 2 to one channel */
|
||||
if ($topic->count() > 2) {
|
||||
@@ -107,7 +108,7 @@ class TopicManager extends WebsocketManager implements TopicManagerInterface
|
||||
public function publish(Topic $topic, ConnectionInterface $connection, $event): void
|
||||
{
|
||||
$user = $this->clientManipulator->getClient($connection);
|
||||
$userName = is_string($user) ? $user : $user->getUsername();
|
||||
$userName = $user->getUserIdentifier();
|
||||
|
||||
/** Save every step by user to db */
|
||||
null === $event['resign']
|
||||
@@ -193,7 +194,7 @@ class TopicManager extends WebsocketManager implements TopicManagerInterface
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function controlUsers(Topic $topic, string $userName, $user): array
|
||||
private function controlUsers(Topic $topic, string $userName, TokenInterface $user): array
|
||||
{
|
||||
$gameAssoc = explode('/', $topic->getId())[2];
|
||||
|
||||
@@ -229,7 +230,7 @@ class TopicManager extends WebsocketManager implements TopicManagerInterface
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function saveUserToDb(Topic $topic, string $userName, $user, $count)
|
||||
private function saveUserToDb(Topic $topic, string $userName, TokenInterface $user, $count)
|
||||
{
|
||||
$gameAssoc = explode('/', $topic->getId())[2];
|
||||
|
||||
@@ -239,7 +240,7 @@ class TopicManager extends WebsocketManager implements TopicManagerInterface
|
||||
->findOneByGameAssoc($gameAssoc);
|
||||
|
||||
/** when the user is not anonym */
|
||||
!is_string($user)
|
||||
null !== $user->getUser()
|
||||
? $this->saveRegisteredUser($userName, $count, $playedGame)
|
||||
: $this->saveAnonUser($userName, $count, $playedGame);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user