finished usage reporter
This commit is contained in:
		
				
					committed by
					
						 Steffen Schröder
						Steffen Schröder
					
				
			
			
				
	
			
			
			
						parent
						
							673eddac3c
						
					
				
				
					commit
					8ced14af6c
				
			| @@ -4,6 +4,7 @@ namespace ManiaControl\Server; | |||||||
|  |  | ||||||
| use ManiaControl\Callbacks\TimerListener; | use ManiaControl\Callbacks\TimerListener; | ||||||
| use ManiaControl\ManiaControl; | use ManiaControl\ManiaControl; | ||||||
|  | use ManiaControl\UpdateManager; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Class reports Usage |  * Class reports Usage | ||||||
| @@ -16,6 +17,7 @@ class UsageReporter implements TimerListener { | |||||||
| 	 */ | 	 */ | ||||||
| 	const UPDATE_MINUTE_COUNT             = 10; | 	const UPDATE_MINUTE_COUNT             = 10; | ||||||
| 	const SETTING_DISABLE_USAGE_REPORTING = 'Disable Usage Reporting'; | 	const SETTING_DISABLE_USAGE_REPORTING = 'Disable Usage Reporting'; | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| 	 * Private Properties | 	 * Private Properties | ||||||
| 	 */ | 	 */ | ||||||
| @@ -28,7 +30,6 @@ class UsageReporter implements TimerListener { | |||||||
| 	 */ | 	 */ | ||||||
| 	public function __construct(ManiaControl $maniaControl) { | 	public function __construct(ManiaControl $maniaControl) { | ||||||
| 		$this->maniaControl = $maniaControl; | 		$this->maniaControl = $maniaControl; | ||||||
| 		//TODO setting |  | ||||||
| 		 | 		 | ||||||
| 		$this->maniaControl->timerManager->registerTimerListening($this, 'reportUsage', 1000 * 60 * self::UPDATE_MINUTE_COUNT); | 		$this->maniaControl->timerManager->registerTimerListening($this, 'reportUsage', 1000 * 60 * self::UPDATE_MINUTE_COUNT); | ||||||
|  |  | ||||||
| @@ -46,23 +47,28 @@ class UsageReporter implements TimerListener { | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$properties                        = array(); | 		$properties                        = array(); | ||||||
| 		$properties['MC_Version']      = ManiaControl::VERSION; | 		$properties['ManiaControlVersion'] = ManiaControl::VERSION; | ||||||
| 		$properties['OperatingSystem']     = php_uname(); | 		$properties['OperatingSystem']     = php_uname(); | ||||||
| 		$properties['PHPVersion']          = phpversion(); | 		$properties['PHPVersion']          = phpversion(); | ||||||
| 		$properties['ServerLogin']         = $this->maniaControl->server->login; | 		$properties['ServerLogin']         = $this->maniaControl->server->login; | ||||||
| 		$properties['TitleId']             = $this->maniaControl->server->titleId; | 		$properties['TitleId']             = $this->maniaControl->server->titleId; | ||||||
| 		$properties['ServerName']          = $this->maniaControl->server->getName(); | 		$properties['ServerName']          = $this->maniaControl->server->getName(); | ||||||
| 		$properties['PlayerCount']         = count($this->maniaControl->playerManager->getPlayers()); | 		$properties['PlayerCount']         = count($this->maniaControl->playerManager->getPlayers()); | ||||||
| 		$properties['MaxPlayers']      = $this->maniaControl->client->getMaxPlayers(); | 		try { | ||||||
|  | 			$maxPlayers               = $this->maniaControl->client->getMaxPlayers(); | ||||||
|  | 			$properties['MaxPlayers'] = $maxPlayers["CurrentValue"]; | ||||||
|  | 		} catch(\Exception $e) { | ||||||
|  | 			//do nothing | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		$json = json_encode($properties); | 		$json = json_encode($properties); | ||||||
| 		$info = base64_encode($json); | 		$info = base64_encode($json); | ||||||
|  |  | ||||||
| 		//TODO make on website | 		$this->maniaControl->fileReader->loadFile(UpdateManager::URL_WEBSERVICE . "/usagereport?info=" . $info, function ($response, $error) { | ||||||
| 	/*	$this->maniaControl->fileReader->loadFile("url/webservice?info=" . $info, function ($response, $error) { | 				$response = json_decode($response); | ||||||
| 				if ($error) { | 				if ($error || !$response) { | ||||||
| 					$this->maniaControl->log("Error while Sending data: " . $error); | 					$this->maniaControl->log("Error while Sending data: " . $error); | ||||||
| 				} | 				} | ||||||
| 			});*/ | 			}); | ||||||
| 	} | 	} | ||||||
| }  | }  | ||||||
		Reference in New Issue
	
	Block a user