ADD: added clocalClientsClass and ping pong check

This commit is contained in:
Henry Winkel
2023-01-19 17:29:35 +01:00
parent 73b15d235a
commit 3474cbd5cb
10 changed files with 212 additions and 34 deletions

View File

@@ -0,0 +1,66 @@
#include <WHISPER/localClients.hpp>
namespace WHISPER {
localClient::localClient(std::uint32_t port,std::string addr,std::uint32_t parentid,std::uint32_t id, std::shared_ptr<zmq::socket_t> clientSocket)
:port_(port),addr_(addr),parentid_(parentid),id_(id),clientSocket_(clientSocket),mx()
{
lastResponse_ = std::time(nullptr);
}
localClient::~localClient()
{
clientSocket_->close();
clientSocket_.reset();
}
std::uint32_t localClient::getPort()
{
std::lock_guard<std::mutex> lock(mx);
return port_;
}
std::string localClient::getAddr()
{
std::lock_guard<std::mutex> lock(mx);
return addr_;
}
std::uint32_t localClient::getParentid()
{
std::lock_guard<std::mutex> lock(mx);
return parentid_;
}
std::uint32_t localClient::getID()
{
std::lock_guard<std::mutex> lock(mx);
return id_;
}
std::time_t localClient::getLastResponse()
{
std::lock_guard<std::mutex> lock(mx);
return lastResponse_;
}
void localClient::setLastResponse(std::time_t time)
{
std::lock_guard<std::mutex> lock(mx);
lastResponse_ = time;
}
std::shared_ptr<zmq::socket_t> localClient::getClientSocket()
{
std::lock_guard<std::mutex> lock(mx);
return clientSocket_;
}
void localClient::addClientSocket(std::shared_ptr<zmq::socket_t> socket)
{
std::lock_guard<std::mutex> lock(mx);
clientSocket_ = socket;
}
}