#pragma once #include #include #include #include namespace scwx::network { /** * @brief NTP Client */ class NtpClient { public: explicit NtpClient(); ~NtpClient(); NtpClient(const NtpClient&) = delete; NtpClient& operator=(const NtpClient&) = delete; NtpClient(NtpClient&&) noexcept; NtpClient& operator=(NtpClient&&) noexcept; bool error(); std::chrono::system_clock::duration time_offset() const; void Start(); void Stop(); void Open(std::string_view host, std::string_view service); void OpenCurrentServer(); void Poll(); std::string RotateServer(); void RunOnce(); void WaitForInitialOffset(); static std::shared_ptr Instance(); private: class Impl; std::unique_ptr p; }; } // namespace scwx::network