/** * @param ConnectedClientInterface $client * @return int|string * @throws ConnectedClientNotFoundException */ protected function findClientRoom(ConnectedClientInterface $client) { foreach ($this->rooms as $roomId => $roomClients) { if (isset($roomClients[$client->getResourceId()])) { return $roomId; } } throw new ConnectedClientNotFoundException($client->getResourceId()); }
/** * @param ConnectedClientInterface $client * @param $roomId */ protected function connectUserToRoom(ConnectedClientInterface $client, $roomId) { $this->rooms[$roomId][$client->getResourceId()] = $client; $this->clients[$client->getResourceId()] = $client; }