chg: usr: make the first working version - the stepping is broken due to the algorythm structure #4
This commit is contained in:
@@ -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