diff --git a/src/fne/network/FNENetwork.cpp b/src/fne/network/FNENetwork.cpp index a01093f8..033b0415 100644 --- a/src/fne/network/FNENetwork.cpp +++ b/src/fne/network/FNENetwork.cpp @@ -89,6 +89,7 @@ FNENetwork::FNENetwork(HostFNE* host, const std::string& address, uint16_t port, m_peers(), m_maintainenceTimer(1000U, pingTime), m_updateLookupTimer(1000U, (updateLookupTime * 60U)), + m_forceListUpdate(false), m_callInProgress(false), m_verbose(verbose) { @@ -166,7 +167,7 @@ void FNENetwork::clock(uint32_t ms) } m_updateLookupTimer.clock(ms); - if (m_updateLookupTimer.isRunning() && m_updateLookupTimer.hasExpired()) { + if ((m_updateLookupTimer.isRunning() && m_updateLookupTimer.hasExpired()) || m_forceListUpdate) { writeWhitelistRIDs(); writeBlacklistRIDs(); m_frameQueue->flushQueue(); @@ -176,6 +177,7 @@ void FNENetwork::clock(uint32_t ms) m_frameQueue->flushQueue(); m_updateLookupTimer.start(); + m_forceListUpdate = false; } sockaddr_storage address; diff --git a/src/fne/network/FNENetwork.h b/src/fne/network/FNENetwork.h index ce8e1192..e11c313a 100644 --- a/src/fne/network/FNENetwork.h +++ b/src/fne/network/FNENetwork.h @@ -239,6 +239,7 @@ namespace network Timer m_maintainenceTimer; Timer m_updateLookupTimer; + bool m_forceListUpdate; bool m_callInProgress; bool m_verbose; diff --git a/src/fne/network/RESTAPI.cpp b/src/fne/network/RESTAPI.cpp index 39e47916..f450386a 100644 --- a/src/fne/network/RESTAPI.cpp +++ b/src/fne/network/RESTAPI.cpp @@ -256,7 +256,9 @@ void RESTAPI::initializeEndpoints() m_dispatcher.match(GET_VERSION).get(REST_API_BIND(RESTAPI::restAPI_GetVersion, this)); m_dispatcher.match(GET_STATUS).get(REST_API_BIND(RESTAPI::restAPI_GetStatus, this)); - m_dispatcher.match(GET_PEERLIST).get(REST_API_BIND(RESTAPI::restAPI_GetPeerList, this)); + m_dispatcher.match(FNE_GET_PEERLIST).get(REST_API_BIND(RESTAPI::restAPI_GetPeerList, this)); + + m_dispatcher.match(FNE_GET_FORCE_UPDATE).get(REST_API_BIND(RESTAPI::restAPI_GetForceUpdate, this)); } /// @@ -489,3 +491,24 @@ void RESTAPI::restAPI_GetPeerList(const HTTPPayload& request, HTTPPayload& reply response["peers"].set(peers); reply.payload(response); } + +/// +/// +/// +/// +/// +/// +void RESTAPI::restAPI_GetForceUpdate(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) +{ + if (!validateAuth(request, reply)) { + return; + } + + json::object response = json::object(); + setResponseDefaultStatus(response); + if (m_network != nullptr) { + m_network->m_forceListUpdate = true; + } + + reply.payload(response); +} diff --git a/src/fne/network/RESTAPI.h b/src/fne/network/RESTAPI.h index 30f490a8..de81b969 100644 --- a/src/fne/network/RESTAPI.h +++ b/src/fne/network/RESTAPI.h @@ -110,6 +110,9 @@ private: void restAPI_GetStatus(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); /// void restAPI_GetPeerList(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); + + /// + void restAPI_GetForceUpdate(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); }; #endif // __REST_API_H__ diff --git a/src/fne/network/RESTDefines.h b/src/fne/network/RESTDefines.h index c27e935d..2620f83c 100644 --- a/src/fne/network/RESTDefines.h +++ b/src/fne/network/RESTDefines.h @@ -33,6 +33,8 @@ // Constants // --------------------------------------------------------------------------- -#define GET_PEERLIST "/peerlist" +#define FNE_GET_PEERLIST "/peerlist" + +#define FNE_GET_FORCE_UPDATE "/force-update" #endif // __FNE_REST_DEFINES_H__ diff --git a/src/remote/RESTClientMain.cpp b/src/remote/RESTClientMain.cpp index 701d26f5..e0fabdcb 100644 --- a/src/remote/RESTClientMain.cpp +++ b/src/remote/RESTClientMain.cpp @@ -54,7 +54,9 @@ #define RCD_GET_VERSION "version" #define RCD_GET_STATUS "status" #define RCD_GET_VOICE_CH "voice-ch" -#define RCD_GET_PEERLIST "peerlist" + +#define RCD_FNE_GET_PEERLIST "fne-peerlist" +#define RCD_FNE_GET_FORCEUPDATE "fne-force-update" #define RCD_MODE "mdm-mode" #define RCD_MODE_OPT_IDLE "idle" @@ -189,7 +191,9 @@ void usage(const char* message, const char* arg) reply += " version Display current version of host\r\n"; reply += " status Display current settings and operation mode\r\n"; reply += " voice-ch Retrieves the list of configured voice channels\r\n"; - reply += " peerlist Retrieves the list of connected peers (FNE only)\r\n"; + reply += "\r\n"; + reply += " peerlist Retrieves the list of connected peers (Conference FNE only)\r\n"; + reply += " fne-force-update Forces the FNE to send list update (Conference FNE only)\r\n"; reply += "\r\n"; reply += " mdm-mode Set current mode of host (idle, lockout, dmr, p25, nxdn)\r\n"; reply += " mdm-kill Causes the host to quit\r\n"; @@ -432,8 +436,11 @@ int main(int argc, char** argv) else if (rcom == RCD_GET_VOICE_CH) { retCode = client->send(HTTP_GET, GET_VOICE_CH, json::object(), response); } - else if (rcom == RCD_GET_PEERLIST) { - retCode = client->send(HTTP_GET, GET_PEERLIST, json::object(), response); + else if (rcom == RCD_FNE_GET_PEERLIST) { + retCode = client->send(HTTP_GET, FNE_GET_PEERLIST, json::object(), response); + } + else if (rcom == RCD_FNE_GET_FORCEUPDATE) { + retCode = client->send(HTTP_GET, FNE_GET_FORCE_UPDATE, json::object(), response); } else if (rcom == RCD_MODE && argCnt >= 1U) { std::string mode = getArgString(args, 0U);