Private
Public Access
1
0

current username checked && refactor && remove players in channel when they are more than 2

This commit is contained in:
2016-10-31 18:07:37 +01:00
parent 5b03dc2c28
commit db2c0c8c30
7 changed files with 31 additions and 21 deletions

View File

@@ -43,12 +43,17 @@ class AcmeTopic implements TopicInterface
$user = $this->clientManipulator->getClient($connection);
$userName = is_string($user) ? $user : $user->getUsername();
$topic->broadcast([
'userTopicId' => $connection->resourceId,
'channel' => $topic->getId(),
'user' => $userName,
'userCnt' => $topic->count()
]);
/** if more user wants to connect than 2 to one channel */
if ($topic->count() > 2) {
$topic->remove($connection);
} else {
$topic->broadcast([
'userTopicId' => $connection->resourceId,
'channel' => $topic->getId(),
'user' => $userName,
'userCnt' => $topic->count()
]);
}
}
/**