Private
Public Access
1
0

ssl handling #22 && reconnection issues #20, #21

This commit is contained in:
2016-11-30 20:15:56 +01:00
parent e6264c4eb0
commit 50b3663889
10 changed files with 199 additions and 57 deletions

View File

@@ -194,14 +194,17 @@ class MineseekerTopic implements TopicInterface
->getRepository('MineSeekerBundle:PlayedGame')
->findOneByGameAssoc($gameAssoc);
/** @var $users {array} */
$users = $this->getUserCollection($playedGame);
$red = "" !== $users['red'] || "" !== $users['redAnon'] ? 1 : 0;
$blue = "" !== $users['blue'] || "" !== $users['blueAnon'] ? 1 : 0;
$one = $topic->count() === 1;
$two = $topic->count() === 2;
/** This checks it is a reconnection */
if (
(null !== $users['red'] || null !== $users['redAnon']) &&
(null !== $users['blue'] || null !== $users['blueAnon'])
) {
/** @var $users array Save users to database */
if (($one && ($red + $blue === 0)) || ($two && ($red + $blue === 1))) {
/** @var $users {array} w/ save users to database */
$users = $this->saveUserToDb($topic, $userName, $user, $topic->count());
}
@@ -226,6 +229,7 @@ class MineseekerTopic implements TopicInterface
->getRepository('MineSeekerBundle:PlayedGame')
->findOneByGameAssoc($gameAssoc);
/** the user is not anonym */
if (!is_string($user)) {
$FOSUser = $this->em
->getRepository('JotunheimrUserBundle:User')
@@ -234,7 +238,6 @@ class MineseekerTopic implements TopicInterface
if ($count == 1) {
/** @var $random {integer} Active player: red: 0, blue: 1 */
$random = rand(0, 1);
!$random ? $playedGame->setRed($FOSUser) : $playedGame->setBlue($FOSUser);
} else {
null === $playedGame->getRed() && null === $playedGame->getRedAnon()
@@ -246,12 +249,12 @@ class MineseekerTopic implements TopicInterface
$anon = new Gamer();
$anon->setUserName($userName);
$anon->setConnTimestamp(new \DateTime());
$this->em->persist($anon);
if ($count == 1) {
/** @var $random {integer} Active player: red: 0, blue: 1 */
$random = rand(0, 1);
!$random ? $playedGame->setRedAnon($anon) : $playedGame->setBlueAnon($anon);
} else {
null === $playedGame->getRed() && null === $playedGame->getRedAnon()