added maxage argument to HTTP/JSON port (fixes #116)
This commit is contained in:
+1
-1
@@ -13,7 +13,7 @@
|
|||||||
* changed docker image to be smaller size and fixed missing library dependencies
|
* changed docker image to be smaller size and fixed missing library dependencies
|
||||||
* added automatic reconnect to MQTT broker
|
* added automatic reconnect to MQTT broker
|
||||||
* changed logging for messages from "updated" to "received" and "sent" depending on who initiated the request
|
* changed logging for messages from "updated" to "received" and "sent" depending on who initiated the request
|
||||||
* added support for serving .csv files to HTTP/JSON port
|
* added support for serving .csv files and new argument maxage to HTTP/JSON port
|
||||||
|
|
||||||
|
|
||||||
# 3.1 (2017-12-26)
|
# 3.1 (2017-12-26)
|
||||||
|
|||||||
@@ -1602,6 +1602,7 @@ result_t MainLoop::executeGet(const vector<string>& args, bool* connected, ostri
|
|||||||
bool numeric = false, valueName = false, required = false, full = false, withWrite = false, raw = false;
|
bool numeric = false, valueName = false, required = false, full = false, withWrite = false, raw = false;
|
||||||
bool withDefinition = false;
|
bool withDefinition = false;
|
||||||
OutputFormat verbosity = OF_NAMES;
|
OutputFormat verbosity = OF_NAMES;
|
||||||
|
time_t maxAge = -1;
|
||||||
size_t argPos = 1;
|
size_t argPos = 1;
|
||||||
string uri = args[argPos++];
|
string uri = args[argPos++];
|
||||||
int type = -1;
|
int type = -1;
|
||||||
@@ -1655,6 +1656,9 @@ result_t MainLoop::executeGet(const vector<string>& args, bool* connected, ostri
|
|||||||
full = parseBoolQuery(value);
|
full = parseBoolQuery(value);
|
||||||
} else if (qname == "required") {
|
} else if (qname == "required") {
|
||||||
required = parseBoolQuery(value);
|
required = parseBoolQuery(value);
|
||||||
|
} else if (qname == "maxage") {
|
||||||
|
maxAge = parseInt(value.c_str(), 10, 0, 24*60*60, &ret);
|
||||||
|
required = true;
|
||||||
} else if (qname == "write") {
|
} else if (qname == "write") {
|
||||||
withWrite = parseBoolQuery(value);
|
withWrite = parseBoolQuery(value);
|
||||||
} else if (qname == "raw") {
|
} else if (qname == "raw") {
|
||||||
@@ -1677,6 +1681,8 @@ result_t MainLoop::executeGet(const vector<string>& args, bool* connected, ostri
|
|||||||
|
|
||||||
*ostream << "{";
|
*ostream << "{";
|
||||||
string lastCircuit;
|
string lastCircuit;
|
||||||
|
time_t now;
|
||||||
|
time(&now);
|
||||||
time_t maxLastUp = 0;
|
time_t maxLastUp = 0;
|
||||||
if (ret == RESULT_OK) {
|
if (ret == RESULT_OK) {
|
||||||
bool first = true;
|
bool first = true;
|
||||||
@@ -1696,7 +1702,7 @@ result_t MainLoop::executeGet(const vector<string>& args, bool* connected, ostri
|
|||||||
m_messages->addPollMessage(false, message);
|
m_messages->addPollMessage(false, message);
|
||||||
}
|
}
|
||||||
time_t lastup = message->getLastUpdateTime();
|
time_t lastup = message->getLastUpdateTime();
|
||||||
if (lastup == 0 && required) {
|
if (required && (lastup == 0 || (maxAge >=0 && lastup + maxAge > now))) {
|
||||||
// read directly from bus
|
// read directly from bus
|
||||||
if (message->isPassive()) {
|
if (message->isPassive()) {
|
||||||
continue; // not possible to actively read this message
|
continue; // not possible to actively read this message
|
||||||
|
|||||||
Reference in New Issue
Block a user