finished usage reporter
This commit is contained in:
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,8 +30,7 @@ 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);
|
||||||
|
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_DISABLE_USAGE_REPORTING, false);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_DISABLE_USAGE_REPORTING, false);
|
||||||
@ -45,24 +46,29 @@ class UsageReporter implements TimerListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$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);
|
||||||
}
|
}
|
||||||
});*/
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user