implement confernece FNE API to force list updates on demand; better organize FNE dvmcmd commands;

pull/48/head
Bryan Biedenkapp 2 years ago
parent bf72dcbee8
commit 2226e1e6f7

@ -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;

@ -239,6 +239,7 @@ namespace network
Timer m_maintainenceTimer;
Timer m_updateLookupTimer;
bool m_forceListUpdate;
bool m_callInProgress;
bool m_verbose;

@ -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));
}
/// <summary>
@ -489,3 +491,24 @@ void RESTAPI::restAPI_GetPeerList(const HTTPPayload& request, HTTPPayload& reply
response["peers"].set<json::array>(peers);
reply.payload(response);
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="reply"></param>
/// <param name="match"></param>
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);
}

@ -110,6 +110,9 @@ private:
void restAPI_GetStatus(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match);
/// <summary></summary>
void restAPI_GetPeerList(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match);
/// <summary></summary>
void restAPI_GetForceUpdate(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match);
};
#endif // __REST_API_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__

@ -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 <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);

Loading…
Cancel
Save

Powered by TurnKey Linux.