mirror of
https://github.com/eclipse/paho.mqtt-sn.embedded-c.git
synced 2025-12-16 08:56:51 +01:00
Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "MQTTSNGWClient.h"
|
||||
#include "MQTTSNGateway.h"
|
||||
#include "SensorNetwork.h"
|
||||
#include "MQTTSNGWForwarder.h"
|
||||
#include "Network.h"
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
@@ -75,7 +76,7 @@ bool ClientList::authorize(const char* fileName)
|
||||
{
|
||||
FILE* fp;
|
||||
char buf[MAX_CLIENTID_LENGTH + 256];
|
||||
size_t pos;;
|
||||
size_t pos;
|
||||
bool secure;
|
||||
bool stable;
|
||||
SensorNetAddress netAddr;
|
||||
@@ -167,6 +168,11 @@ bool ClientList::setPredefinedTopics(const char* fileName)
|
||||
fclose(fp);
|
||||
rc = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITELOG("Can not open the Predefined Topic List. %s\n", fileName);
|
||||
return false;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -196,6 +202,11 @@ void ClientList::erase(Client*& client)
|
||||
_endClient = prev;
|
||||
}
|
||||
_clientCnt--;
|
||||
Forwarder* fwd = client->getForwarder();
|
||||
if ( fwd )
|
||||
{
|
||||
fwd->eraseClient(client);
|
||||
}
|
||||
delete client;
|
||||
client = 0;
|
||||
_mutex.unlock();
|
||||
@@ -204,19 +215,22 @@ void ClientList::erase(Client*& client)
|
||||
|
||||
Client* ClientList::getClient(SensorNetAddress* addr)
|
||||
{
|
||||
_mutex.lock();
|
||||
Client* client = _firstClient;
|
||||
if ( addr )
|
||||
{
|
||||
_mutex.lock();
|
||||
Client* client = _firstClient;
|
||||
|
||||
while (client != 0)
|
||||
{
|
||||
if (client->getSensorNetAddress()->isMatch(addr) )
|
||||
{
|
||||
_mutex.unlock();
|
||||
return client;
|
||||
}
|
||||
client = client->_nextClient;
|
||||
}
|
||||
_mutex.unlock();
|
||||
while (client != 0)
|
||||
{
|
||||
if (client->getSensorNetAddress()->isMatch(addr) )
|
||||
{
|
||||
_mutex.unlock();
|
||||
return client;
|
||||
}
|
||||
client = client->_nextClient;
|
||||
}
|
||||
_mutex.unlock();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -401,6 +415,7 @@ Client::Client(bool secure)
|
||||
_clientSleepPacketQue.setMaxSize(MAX_SAVED_PUBLISH);
|
||||
_hasPredefTopic = false;
|
||||
_holdPingRequest = false;
|
||||
_forwarder = 0;
|
||||
}
|
||||
|
||||
Client::~Client()
|
||||
@@ -519,6 +534,16 @@ void Client::setKeepAlive(MQTTSNPacket* packet)
|
||||
}
|
||||
}
|
||||
|
||||
void Client::setForwarder(Forwarder* forwarder)
|
||||
{
|
||||
_forwarder = forwarder;
|
||||
}
|
||||
|
||||
Forwarder* Client::getForwarder(void)
|
||||
{
|
||||
return _forwarder;
|
||||
}
|
||||
|
||||
void Client::setSessionStatus(bool status)
|
||||
{
|
||||
_sessionStatus = status;
|
||||
|
||||
Reference in New Issue
Block a user