FIX: fixed the tcp client

This commit is contained in:
Henry Winkel
2023-07-05 18:20:37 +02:00
parent 7fa17e0397
commit 9ffa95877b
2 changed files with 7 additions and 2 deletions

View File

@@ -38,6 +38,9 @@ namespace DirectCommunication
std::thread Worker_; std::thread Worker_;
std::atomic_bool stopWorker_; std::atomic_bool stopWorker_;
std::atomic_bool isConnected = true;
WHISPER::threadSafeQueue<std::string> receivedMessages_; WHISPER::threadSafeQueue<std::string> receivedMessages_;

View File

@@ -41,7 +41,9 @@ namespace DirectCommunication
zmq::message_t zmqMsg(msg.begin(),msg.end()); zmq::message_t zmqMsg(msg.begin(),msg.end());
socket_.send(zmqMsg,zmq::send_flags::dontwait); if (isConnected == true) {
socket_.send(zmqMsg,zmq::send_flags::dontwait);
}
} }
@@ -70,7 +72,7 @@ namespace DirectCommunication
if (msg.to_string() == "CLOSE") if (msg.to_string() == "CLOSE")
{ {
isConnected = false;
socket_.disconnect("tcp://"+serverAddress_+":"+std::to_string(port_)); socket_.disconnect("tcp://"+serverAddress_+":"+std::to_string(port_));
}else }else