centralize jquery && bugfix mysql auto-termination problem w/ user auth
This commit is contained in:
44
src/Mine/SeekerBundle/Periodic/MinePeriodic.php
Normal file
44
src/Mine/SeekerBundle/Periodic/MinePeriodic.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Mine\SeekerBundle\Periodic;
|
||||
|
||||
use Doctrine\DBAL\Driver\PDOException;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Gos\Bundle\WebSocketBundle\Periodic\PeriodicInterface;
|
||||
|
||||
class MinePeriodic implements PeriodicInterface
|
||||
{
|
||||
private $em;
|
||||
|
||||
public function __construct(EntityManager $entityManager)
|
||||
{
|
||||
$this->em = $entityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is executed every 5 seconds.
|
||||
*
|
||||
* For more advanced functionality, try injecting a Topic Service to perform actions on your connections every x seconds.
|
||||
*/
|
||||
public function tick()
|
||||
{
|
||||
try {
|
||||
$connection = $this->em->getConnection();
|
||||
|
||||
if (false === $connection->ping()) {
|
||||
$connection->close();
|
||||
$connection->connect();
|
||||
}
|
||||
} catch(PDOException $ex) {
|
||||
throw PDOException::class;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getTimeout()
|
||||
{
|
||||
return 777;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user