GameQ
GameQ copied to clipboard
Add option to only return `normalized` data.
Add an option to only return normalized data (data prefixed with gq_
). Right now, a bunch of useless server information is returned when not requested. Adding some sort of option to only get X,Y,Z values would be nice. It would also prevent wasted memory (assuming this is implemented corrected) when querying servers that return more than necessary data like TeamSpeak or servers that don't return valid data.
For those who need this sort of functionality now, heres a quick array_filter()
you can run.
$GameQ = new \GameQ\GameQ();
$GameQ->addServers($servers);
$GameQ->addFilter('normalise');
$results = $GameQ->process();
foreach ($results as $id => $result) {
$result = array_filter($result, function ($key) {
return (preg_match('/gq\_.+/', $key) === 1);
}, ARRAY_FILTER_USE_KEY);
$results[$id] = $result;
}
It would be possible to add a filter to only return the gq_ data. Using a filter will actually make things slightly slower because it is another process to jump through to filter out all of the non gq_ prefixed data.
All of the data is returned when process() is invoked because there is no way to tell the server when querying it I only want these specific data points and ignore the rest. Depending on the server response format the specific data point you want may be near the end of the data stream and the only way to get to it is to parse everything before it. There is no way to jump forward that would provide any speed increase. Not adding items to the response array would save some memory but since it is all text it wouldn't be significant unless you are running 100's of servers at a time.
Correct but this also would help prevent the issue I had in #378. Depending how each game's query works, you could theoretically for a lot of games request just specific data. Such as TS3, you can just request online users instead of requesting the entire channel tree, etc.
Stale issue message