FIX:fixed some issues in the tcp client
This commit is contained in:
@@ -42,7 +42,7 @@ namespace DirectCommunication
|
|||||||
std::thread Worker_;
|
std::thread Worker_;
|
||||||
std::atomic_bool stopWorker_;
|
std::atomic_bool stopWorker_;
|
||||||
|
|
||||||
std::atomic_bool isConnected = true;
|
std::atomic_bool isConnected = false;
|
||||||
|
|
||||||
std::function<void(std::string)> MessageHandle_ = nullptr;
|
std::function<void(std::string)> MessageHandle_ = nullptr;
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ namespace DirectCommunication
|
|||||||
|
|
||||||
socket_.connect("tcp://"+serverAddress_+":"+std::to_string(port_));
|
socket_.connect("tcp://"+serverAddress_+":"+std::to_string(port_));
|
||||||
socket_.set(zmq::sockopt::rcvtimeo,100);
|
socket_.set(zmq::sockopt::rcvtimeo,100);
|
||||||
|
socket_.set(zmq::sockopt::sndtimeo,500);
|
||||||
|
|
||||||
Worker_ = std::thread(&DirectCommunicationClient::workerFunc_,this);
|
Worker_ = std::thread(&DirectCommunicationClient::workerFunc_,this);
|
||||||
stopWorker_ = false;
|
stopWorker_ = false;
|
||||||
@@ -74,7 +75,7 @@ namespace DirectCommunication
|
|||||||
|
|
||||||
if (recv > 0)
|
if (recv > 0)
|
||||||
{
|
{
|
||||||
|
isConnected = true;
|
||||||
if (msg.to_string() == "CLOSE")
|
if (msg.to_string() == "CLOSE")
|
||||||
{
|
{
|
||||||
isConnected = false;
|
isConnected = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user