TimeProvider.h 709 B

12345678910111213141516171819202122232425262728293031323334
  1. #pragma once
  2. #include <stdint.h>
  3. #include <vector>
  4. #include "Utils.h"
  5. namespace cspot {
  6. class TimeProvider {
  7. private:
  8. unsigned long long timestampDiff;
  9. public:
  10. /**
  11. * @brief Bypasses the need for NTP server sync by syncing with spotify's servers
  12. *
  13. */
  14. TimeProvider();
  15. /**
  16. * @brief Syncs the TimeProvider with spotify server's timestamp
  17. *
  18. * @param pongPacket pong packet containing timestamp
  19. */
  20. void syncWithPingPacket(const std::vector<uint8_t>& pongPacket);
  21. /**
  22. * @brief Get current timestamp synced with spotify servers
  23. *
  24. * @return unsigned long long timestamp
  25. */
  26. unsigned long long getSyncedTimestamp();
  27. };
  28. } // namespace cspot