From 668043e6767b8b8b54658d69df9d39f56ae3b659 Mon Sep 17 00:00:00 2001 From: phuicy Date: Sun, 18 Sep 2022 15:04:37 +0100 Subject: [PATCH] Bugfix: (@webercheng) --- .../Private/ROSIntegrationGameInstance.cpp | 2 +- .../Private/rosbridge2cpp/TCPConnection.cpp | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Source/ROSIntegration/Private/ROSIntegrationGameInstance.cpp b/Source/ROSIntegration/Private/ROSIntegrationGameInstance.cpp index 122aaf8..889b963 100644 --- a/Source/ROSIntegration/Private/ROSIntegrationGameInstance.cpp +++ b/Source/ROSIntegration/Private/ROSIntegrationGameInstance.cpp @@ -86,7 +86,7 @@ void UROSIntegrationGameInstance::Init() if (!bTimerSet) { bTimerSet = true; - GetTimerManager().SetTimer(TimerHandle_CheckHealth, this, &UROSIntegrationGameInstance::CheckROSBridgeHealth, 1.0f, true, 5.0f); + GetTimerManager().SetTimer(TimerHandle_CheckHealth, this, &UROSIntegrationGameInstance::CheckROSBridgeHealth, 5.0f, true, 5.0f); } if (bIsConnected) diff --git a/Source/ROSIntegration/Private/rosbridge2cpp/TCPConnection.cpp b/Source/ROSIntegration/Private/rosbridge2cpp/TCPConnection.cpp index 998c3d2..b176f92 100644 --- a/Source/ROSIntegration/Private/rosbridge2cpp/TCPConnection.cpp +++ b/Source/ROSIntegration/Private/rosbridge2cpp/TCPConnection.cpp @@ -39,9 +39,19 @@ bool TCPConnection::Init(std::string ip_addr, int port) std::cout << "Unable to set requested receiver buffer size" << std::endl; }*/ - if (!_sock->Connect(*addr)) + bool bConnected = false; + _sock->SetNonBlocking(true); + bConnected = _sock->Connect(*addr); + _sock->SetNonBlocking(false); + // If using _sock->Wait also blocks + if (bConnected ) //&& _sock->Wait(ESocketWaitConditions::WaitForWrite, FTimespan::FromSeconds(2))) + { + // do nothing + } + else + { return false; - + } // Setting up the receiver thread UE_LOG(LogROS, Display, TEXT("Setting up receiver thread ..."));