Added support for arrays of requests in totals/clients API calls.
This commit is contained in:
parent
391daaaa71
commit
840cfaabed
2 changed files with 30 additions and 2 deletions
|
@ -696,10 +696,22 @@ int main(int argc, char ** argv){
|
||||||
Controller::Storage["log"].null();
|
Controller::Storage["log"].null();
|
||||||
}
|
}
|
||||||
if (Request.isMember("clients")){
|
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")){
|
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"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,13 @@ bool Controller::hasViewers(std::string streamName){
|
||||||
/// "time": 1234567
|
/// "time": 1234567
|
||||||
/// }
|
/// }
|
||||||
/// ~~~~~~~~~~~~~~~
|
/// ~~~~~~~~~~~~~~~
|
||||||
|
/// OR
|
||||||
|
/// ~~~~~~~~~~~~~~~{.js}
|
||||||
|
/// [
|
||||||
|
/// {},//request object as above
|
||||||
|
/// {}//repeat the structure as many times as wanted
|
||||||
|
/// ]
|
||||||
|
/// ~~~~~~~~~~~~~~~
|
||||||
/// and are responded to as:
|
/// and are responded to as:
|
||||||
/// ~~~~~~~~~~~~~~~{.js}
|
/// ~~~~~~~~~~~~~~~{.js}
|
||||||
/// {
|
/// {
|
||||||
|
@ -115,6 +122,7 @@ bool Controller::hasViewers(std::string streamName){
|
||||||
/// "data": [[x, y, z], [x, y, z], [x, y, z]]
|
/// "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){
|
void Controller::fillClients(JSON::Value & req, JSON::Value & rep){
|
||||||
//first, figure out the timestamp wanted
|
//first, figure out the timestamp wanted
|
||||||
long long int reqTime = 0;
|
long long int reqTime = 0;
|
||||||
|
@ -288,6 +296,13 @@ class totalsData {
|
||||||
/// "end": 1234567
|
/// "end": 1234567
|
||||||
/// }
|
/// }
|
||||||
/// ~~~~~~~~~~~~~~~
|
/// ~~~~~~~~~~~~~~~
|
||||||
|
/// OR
|
||||||
|
/// ~~~~~~~~~~~~~~~{.js}
|
||||||
|
/// [
|
||||||
|
/// {},//request object as above
|
||||||
|
/// {}//repeat the structure as many times as wanted
|
||||||
|
/// ]
|
||||||
|
/// ~~~~~~~~~~~~~~~
|
||||||
/// and are responded to as:
|
/// and are responded to as:
|
||||||
/// ~~~~~~~~~~~~~~~{.js}
|
/// ~~~~~~~~~~~~~~~{.js}
|
||||||
/// {
|
/// {
|
||||||
|
@ -303,6 +318,7 @@ class totalsData {
|
||||||
/// "data": [[x, y, z], [x, y, z], [x, y, z]]
|
/// "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){
|
void Controller::fillTotals(JSON::Value & req, JSON::Value & rep){
|
||||||
//first, figure out the timestamps wanted
|
//first, figure out the timestamps wanted
|
||||||
long long int reqStart = 0;
|
long long int reqStart = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue