add new websocket topic - userList - and handle it
This commit is contained in:
@@ -63,7 +63,8 @@ class MineseekerTopic implements TopicInterface
|
||||
'channel' => $topic->getId(),
|
||||
'user' => $userName,
|
||||
'userCnt' => $topic->count(),
|
||||
'users' => $users
|
||||
'users' => $users,
|
||||
'steps' => $this->getSteps($topic),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -180,6 +181,28 @@ class MineseekerTopic implements TopicInterface
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
private function getSteps($topic)
|
||||
{
|
||||
$this->reConnect();
|
||||
$gameAssoc = explode('/', $topic->getId())[2];
|
||||
|
||||
$playedGame = $this->em
|
||||
->getRepository('MineSeekerBundle:PlayedGame')
|
||||
->findOneByGameAssoc($gameAssoc);
|
||||
|
||||
$steps = array();
|
||||
|
||||
foreach ($playedGame->getStep()->toArray() as $item) {
|
||||
$steps[] = array(
|
||||
'row' => $item->getRow(),
|
||||
'col' => $item->getCol(),
|
||||
'wBomb' => $item->getWBomb(),
|
||||
);
|
||||
}
|
||||
|
||||
return base64_encode(json_encode($steps));
|
||||
}
|
||||
|
||||
/**
|
||||
* Control all users in a channel
|
||||
*
|
||||
@@ -300,7 +323,7 @@ class MineseekerTopic implements TopicInterface
|
||||
$connection->close();
|
||||
$connection->connect();
|
||||
}
|
||||
} catch(PDOException $ex) {
|
||||
} catch (PDOException $ex) {
|
||||
throw PDOException::class;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user