diff --git a/includes/ajaxHandler/arenateam.class.php b/includes/ajaxHandler/arenateam.class.php index 8d609e61..093555e7 100644 --- a/includes/ajaxHandler/arenateam.class.php +++ b/includes/ajaxHandler/arenateam.class.php @@ -76,8 +76,7 @@ class AjaxArenaTeam extends AjaxHandler */ protected function handleStatus() : string { - $response = Profiler::resyncStatus(Type::ARENA_TEAM, $this->_get['id']); - return Util::toJSON($response); + return Profiler::resyncStatus(Type::ARENA_TEAM, $this->_get['id']); } } diff --git a/includes/ajaxHandler/guild.class.php b/includes/ajaxHandler/guild.class.php index 74c9edb0..97ac6634 100644 --- a/includes/ajaxHandler/guild.class.php +++ b/includes/ajaxHandler/guild.class.php @@ -76,8 +76,7 @@ class AjaxGuild extends AjaxHandler */ protected function handleStatus() : string { - $response = Profiler::resyncStatus(Type::GUILD, $this->_get['id']); - return Util::toJSON($response); + return Profiler::resyncStatus(Type::GUILD, $this->_get['id']); } } diff --git a/includes/ajaxHandler/profile.class.php b/includes/ajaxHandler/profile.class.php index a3bd2435..3b61851c 100644 --- a/includes/ajaxHandler/profile.class.php +++ b/includes/ajaxHandler/profile.class.php @@ -307,8 +307,7 @@ class AjaxProfile extends AjaxHandler return Util::toJSON([1, [PR_QUEUE_STATUS_ERROR, 0, 0, PR_QUEUE_ERROR_CHAR]]); } - $response = Profiler::resyncStatus(Type::PROFILE, $ids); - return Util::toJSON($response); + return Profiler::resyncStatus(Type::PROFILE, $ids); } /* params (get)) diff --git a/includes/components/profiler.class.php b/includes/components/profiler.class.php index 015be6b2..2863ac1d 100644 --- a/includes/components/profiler.class.php +++ b/includes/components/profiler.class.php @@ -296,9 +296,34 @@ class Profiler return $newId; } - public static function resyncStatus($type, array $subjectGUIDs) + /* return + [ + nQueueProcesses, + [statusCode, timeToRefresh, curQueuePos, errorCode, nResyncs], + [] + ... + ] + + statusCode: + 0: end the request + 1: waiting + 2: working... + 3: ready; click to view + 4: error / retry + timeToRefresh: + msec till the client may ask for another update + curQueuePos: + position in the queue + errorCode: + 0: unk error + 1: char does not exist + 2: armory gone + nResyncs: + ??? .. if !nResyncs && !timeToRefresh prints "Adding to queue..." but will not ping the server for updates...? + */ + public static function resyncStatus(int $type, array $subjectGUIDs) : string { - $response = [Cfg::get('PROFILER_ENABLE') ? 2 : 0]; // in theory you could have multiple queues; used as divisor for: (15 / x) + 2 + $response = [Cfg::get('PROFILER_ENABLE') ? 2 : 0]; // in theory you could have multiple queues; used as divisor in wait time estimation: (15 / x) + 2 if (!$subjectGUIDs) $response[] = [PR_QUEUE_STATUS_ENDED, 0, 0, PR_QUEUE_ERROR_CHAR]; else @@ -320,12 +345,12 @@ class Profiler $subjectStatus[$guid]['status'] != PR_QUEUE_STATUS_READY ? Cfg::get('PROFILER_RESYNC_PING') : 0, array_search($type.':'.$guid, $queue) + 1, 0, - 1 // nResycTries - unsure about this one + 1 // nResyncs - unsure about this one ); } } - return $response; + return Util::toJSON($response); } public static function getCharFromRealm($realmId, $charGuid)