Added support for arrays of requests in totals/clients API calls.

This commit is contained in:
Thulinma 2014-06-11 17:58:49 +02:00
parent 391daaaa71
commit 840cfaabed
2 changed files with 30 additions and 2 deletions

View file

@ -696,10 +696,22 @@ int main(int argc, char ** argv){
Controller::Storage["log"].null();
}
if (Request.isMember("clients")){
Controller::fillClients(Request["clients"], Response["clients"]);
if (Request["clients"].isArray()){
for (unsigned int i = 0; i < Request["clients"].size(); ++i){
Controller::fillClients(Request["clients"][i], Response["clients"][i]);
}
}else{
Controller::fillClients(Request["clients"], Response["clients"]);
}
}
if (Request.isMember("totals")){
Controller::fillTotals(Request["totals"], Response["totals"]);
if (Request["totals"].isArray()){
for (unsigned int i = 0; i < Request["totals"].size(); ++i){
Controller::fillTotals(Request["totals"][i], Response["totals"][i]);
}
}else{
Controller::fillTotals(Request["totals"], Response["totals"]);
}
}
}

View file

@ -104,6 +104,13 @@ bool Controller::hasViewers(std::string streamName){
/// "time": 1234567
/// }
/// ~~~~~~~~~~~~~~~
/// OR
/// ~~~~~~~~~~~~~~~{.js}
/// [
/// {},//request object as above
/// {}//repeat the structure as many times as wanted
/// ]
/// ~~~~~~~~~~~~~~~
/// and are responded to as:
/// ~~~~~~~~~~~~~~~{.js}
/// {
@ -115,6 +122,7 @@ bool Controller::hasViewers(std::string streamName){
/// "data": [[x, y, z], [x, y, z], [x, y, z]]
/// }
/// ~~~~~~~~~~~~~~~
/// In case of the second method, the response is an array in the same order as the requests.
void Controller::fillClients(JSON::Value & req, JSON::Value & rep){
//first, figure out the timestamp wanted
long long int reqTime = 0;
@ -288,6 +296,13 @@ class totalsData {
/// "end": 1234567
/// }
/// ~~~~~~~~~~~~~~~
/// OR
/// ~~~~~~~~~~~~~~~{.js}
/// [
/// {},//request object as above
/// {}//repeat the structure as many times as wanted
/// ]
/// ~~~~~~~~~~~~~~~
/// and are responded to as:
/// ~~~~~~~~~~~~~~~{.js}
/// {
@ -303,6 +318,7 @@ class totalsData {
/// "data": [[x, y, z], [x, y, z], [x, y, z]]
/// }
/// ~~~~~~~~~~~~~~~
/// In case of the second method, the response is an array in the same order as the requests.
void Controller::fillTotals(JSON::Value & req, JSON::Value & rep){
//first, figure out the timestamps wanted
long long int reqStart = 0;