 #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;
}

 
 
 
 }