diff --git a/src/OverteClient.cpp b/src/OverteClient.cpp index f719193..4ef0ff4 100644 --- a/src/OverteClient.cpp +++ b/src/OverteClient.cpp @@ -181,16 +181,28 @@ void OverteClient::poll() { sockaddr_storage from{}; socklen_t fromlen = sizeof(from); ssize_t r = ::recvfrom(m_udpFd, buf, sizeof(buf), 0, reinterpret_cast(&from), &fromlen); if (r > 0) { + std::cout << "[OverteClient] <<< Received domain packet (" << r << " bytes)" << std::endl; parseDomainPacket(buf, static_cast(r)); + } else if (r < 0 && errno != EWOULDBLOCK && errno != EAGAIN) { + std::cerr << "[OverteClient] UDP recv error: " << strerror(errno) << std::endl; } // Send periodic ping to domain to keep connection alive static auto lastPing = std::chrono::steady_clock::now(); + static auto lastDomainList = std::chrono::steady_clock::now(); auto now = std::chrono::steady_clock::now(); + if (std::chrono::duration_cast(now - lastPing).count() >= 1) { sendPing(m_udpFd, m_udpAddr, m_udpAddrLen); lastPing = now; } + + // Request domain list periodically if not connected + if (!m_domainConnected && std::chrono::duration_cast(now - lastDomainList).count() >= 2) { + std::cout << "[OverteClient] Retrying domain connection..." << std::endl; + sendDomainConnectRequest(); + lastDomainList = now; + } } // Parse entity server packets