handle prod mysql timeout && graphics improve
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Mine\SeekerBundle\Topic;
|
||||
|
||||
use Doctrine\DBAL\Driver\PDOException;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Gos\Bundle\WebSocketBundle\Client\ClientManipulatorInterface;
|
||||
use Gos\Bundle\WebSocketBundle\Topic\TopicInterface;
|
||||
@@ -43,7 +44,7 @@ class MineseekerTopic implements TopicInterface
|
||||
* @param ConnectionInterface $connection
|
||||
* @param Topic $topic
|
||||
* @param WampRequest $request
|
||||
* @return void
|
||||
* @return void4
|
||||
*/
|
||||
public function onSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
|
||||
{
|
||||
@@ -131,6 +132,7 @@ class MineseekerTopic implements TopicInterface
|
||||
*/
|
||||
private function saveResignToDb($topic, $color)
|
||||
{
|
||||
$this->reConnect();
|
||||
$gameAssoc = explode('/', $topic->getId())[2];
|
||||
|
||||
$playedGame = $this->em
|
||||
@@ -150,6 +152,7 @@ class MineseekerTopic implements TopicInterface
|
||||
*/
|
||||
private function saveStepToDb($topic, $event)
|
||||
{
|
||||
$this->reConnect();
|
||||
$gameAssoc = explode('/', $topic->getId())[2];
|
||||
|
||||
$playedGame = $this->em
|
||||
@@ -184,6 +187,7 @@ class MineseekerTopic implements TopicInterface
|
||||
*/
|
||||
private function saveUserToDb($topic, $userName, $user, $count)
|
||||
{
|
||||
$this->reConnect();
|
||||
$gameAssoc = explode('/', $topic->getId())[2];
|
||||
|
||||
$playedGame = $this->em
|
||||
@@ -234,4 +238,19 @@ class MineseekerTopic implements TopicInterface
|
||||
'blueAnon' => null !== $playedGame->getBlueAnon() ? $playedGame->getBlueAnon()->getUserName() : ''
|
||||
);
|
||||
}
|
||||
|
||||
/** Handle prod MySQL timeout */
|
||||
private function reConnect()
|
||||
{
|
||||
try {
|
||||
$connection = $this->em->getConnection();
|
||||
|
||||
if (false === $connection->ping()) {
|
||||
$connection->close();
|
||||
$connection->connect();
|
||||
}
|
||||
} catch(PDOException $ex) {
|
||||
throw PDOException::class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user