isLoggedIn($f3) ){ // no character found or login timer expired $this->logoutCharacter($f3); // skip route handler and afterroute() $return = false; } } return $return; } /** * get current character and check if it is a valid character * @param \Base $f3 * @return bool * @throws \Exception */ protected function isLoggedIn(\Base $f3): bool { $loginCheck = false; if( $character = $this->getCharacter() ){ if($this->checkLogTimer($f3, $character)){ if($character->isAuthorized() === 'OK'){ $loginCheck = true; } } } return $loginCheck; } /** * checks whether a user/character is currently logged in * @param \Base $f3 * @param Model\CharacterModel $character * @return bool */ private function checkLogTimer(\Base $f3, Model\CharacterModel $character){ $loginCheck = false; if( !$character->dry() && $character->lastLogin ){ // check logIn time $logInTime = new \DateTime($character->lastLogin); $now = new \DateTime(); $timeDiff = $now->diff($logInTime); $minutes = $timeDiff->days * 60 * 24 * 60; $minutes += $timeDiff->h * 60; $minutes += $timeDiff->i; if($minutes <= Config::getPathfinderData('timer.logged')){ $loginCheck = true; } } return $loginCheck; } /** * broadcast map data to clients * -> send over TCP Socket * @param Model\MapModel $map * @return int (number of active connections for this map) * @throws \Exception * @throws \ZMQSocketException */ protected function broadcastMapData(Model\MapModel $map){ $mapData = $this->getFormattedMapData($map); return (int)(new Socket( Config::getSocketUri() ))->sendData('mapUpdate', $mapData); } /** * get formatted Map Data * @param Model\MapModel $map * @return array * @throws \Exception */ protected function getFormattedMapData(Model\MapModel $map){ $mapData = $map->getData(); return [ 'config' => $mapData->mapData, 'data' => [ 'systems' => $mapData->systems, 'connections' => $mapData->connections, ] ]; } }