current username checked && refactor && remove players in channel when they are more than 2
This commit is contained in:
@@ -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()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user