Private
Public Access
1
0

add new websocket topic - userList - and handle it

This commit is contained in:
2017-01-22 15:21:45 +01:00
parent a91172ef7a
commit a3465f6cf9
18 changed files with 680 additions and 83 deletions

View File

@@ -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;
}
}