diff --git a/ntcore/src/main/native/cpp/net/TimeSyncClientServer.cpp b/ntcore/src/main/native/cpp/net/TimeSyncClientServer.cpp index 03c5f8f5d32..518033c1b56 100644 --- a/ntcore/src/main/native/cpp/net/TimeSyncClientServer.cpp +++ b/ntcore/src/main/native/cpp/net/TimeSyncClientServer.cpp @@ -220,7 +220,6 @@ void wpi::TimeSyncClient::UdpCallback(uv::Buffer& buf, size_t nbytes, if (pong.version != 1) { fmt::println("Bad version from server?"); - auto end{std::chrono::high_resolution_clock::now()}; return; } if (pong.message_id != 2) { @@ -282,7 +281,8 @@ void wpi::TimeSyncClient::Start() { using namespace std::chrono_literals; m_pingTimer->timeout.connect(&wpi::TimeSyncClient::Tick, this); - m_loopRunner.ExecSync([this](uv::Loop&) { m_pingTimer->Start(1s, 1s); }); + m_loopRunner.ExecSync( + [this](uv::Loop&) { m_pingTimer->Start(m_loopDelay, m_loopDelay); }); } void wpi::TimeSyncClient::Stop() { diff --git a/ntcore/src/main/native/include/net/TimeSyncClientServer.h b/ntcore/src/main/native/include/net/TimeSyncClientServer.h index 13a2a632401..a83edd87573 100644 --- a/ntcore/src/main/native/include/net/TimeSyncClientServer.h +++ b/ntcore/src/main/native/include/net/TimeSyncClientServer.h @@ -57,7 +57,7 @@ class TimeSyncServer { unsigned flags); public: - TimeSyncServer(int port = 5810, + explicit TimeSyncServer(int port = 5810, std::function timeProvider = nt::Now); /** @@ -92,8 +92,8 @@ class TimeSyncClient { SharedTimerPtr m_pingTimer; std::string m_serverIP; - int m_serverPort; + std::chrono::milliseconds m_loopDelay; std::mutex m_offsetMutex;