BugFix ClientList file name is not shown

Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
tomoaki
2020-02-21 11:29:37 +09:00
parent c37d9334d4
commit ae462989ec
2 changed files with 30 additions and 32 deletions

View File

@@ -67,25 +67,13 @@ void ClientList::setClientList(int type)
{
char param[MQTTSNGW_PARAM_MAX];
string fileName;
GatewayParams* params = theGateway->getGWParams();
if (theGateway->getParam("ClientsList", param) == 0)
{
fileName = string(param);
}
else
{
fileName = params->configDir + string(CLIENT_LIST);
}
theGateway->getParam("ClientsList", param);
fileName = string(param);
if (!createList(fileName.c_str(), type))
{
throw Exception("ClientList::initialize(): No client list defined by the configuration.");
}
if ( params->clientListName == nullptr )
{
params->clientListName = strdup(fileName.c_str());
}
}
void ClientList::setPredefinedTopics(bool aggrecate)
@@ -93,21 +81,11 @@ void ClientList::setPredefinedTopics(bool aggrecate)
char param[MQTTSNGW_PARAM_MAX];
string fileName;
GatewayParams* params = theGateway->getGWParams();
if (theGateway->getParam("PredefinedTopicList", param) == 0)
{
fileName = string(param);
}
else
{
fileName = params->configDir + string(PREDEFINEDTOPIC_FILE);
}
theGateway->getParam("PredefinedTopicList", param);
fileName = string(param);
if ( readPredefinedList(fileName.c_str(), aggrecate) )
{
params->predefinedTopicFileName = strdup(fileName.c_str());
}
readPredefinedList(fileName.c_str(), aggrecate);
}
/**
@@ -125,11 +103,11 @@ void ClientList::setPredefinedTopics(bool aggrecate)
*
* Ex:
* #Client List
* ClientId1,11200@192.168.10.10
* ClientID2,35000@192.168.50.200,unstableLine
* ClientID3,40000@192.168.200.50,secureConnection
* ClientID4,41000@192.168.200.51,unstableLine,secureConnection
* ClientID5,41000@192.168.200.51,unstableLine,secureConnection,QoS-1
* ClientId1,192.168.10.10:11200
* ClientID2,192.168.50.200:35000,unstableLine
* ClientID3,192.168.200.50:40000,secureConnection
* ClientID4,192.168.200.51:41000,unstableLine,secureConnection
* ClientID5,192.168.200.51:41000,unstableLine,secureConnection,QoS-1
*/
bool ClientList::createList(const char* fileName, int type)

View File

@@ -215,6 +215,26 @@ void Gateway::initialize(int argc, char** argv)
}
}
if (getParam("ClientsList", param) == 0)
{
_params.clientListName = strdup(param);
}
if (getParam("PredefinedTopicList", param) == 0)
{
_params.predefinedTopicFileName = strdup(param);
}
if ( _params.clientListName == nullptr )
{
_params.clientListName = strdup(( _params.configDir + string(CLIENT_LIST) ).c_str());
}
if ( _params.predefinedTopicFileName == nullptr )
{
_params.predefinedTopicFileName = strdup(( _params.configDir + string(PREDEFINEDTOPIC_FILE) ).c_str());
}
/* ClientList and Adapters Initialize */
_adapterManager->initialize();