updated to HttpAsyncRequest Structure

This commit is contained in:
kremsy
2017-03-26 20:21:23 +02:00
parent 8e664879d5
commit da94e8c588
3 changed files with 36 additions and 12 deletions

View File

@ -469,6 +469,7 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
// Update last updated time
$map = $this->getMapByUid($mapInfo->uid);
if (!$map) {
// TODO: improve this - error reports about not existing maps
$this->maniaControl->getErrorHandler()->triggerDebugNotice('Map not in List after Insert!');

View File

@ -3,6 +3,7 @@
namespace ManiaControl\Server;
use ManiaControl\Callbacks\TimerListener;
use ManiaControl\Files\AsyncHttpRequest;
use ManiaControl\Logger;
use ManiaControl\ManiaControl;
use ManiaControl\Utils\Formatter;
@ -81,11 +82,16 @@ class UsageReporter implements TimerListener {
$usageReport = json_encode($properties);
$url = ManiaControl::URL_WEBSERVICE . 'usagereport';
$this->maniaControl->getFileReader()->postData($url, function ($response, $error) {
$asyncRequest = new AsyncHttpRequest($this->maniaControl, $url);
$asyncRequest->setContent($usageReport);
$asyncRequest->setCallable(function ($response, $error) {
$response = json_decode($response);
if ($error || !$response) {
Logger::logError('Error while Sending data: ' . print_r($error, true));
}
}, $usageReport);
});
$asyncRequest->postData();
}
}