Device.h 891 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef UNIFI_DEVICE_H
  2. #define UNIFI_DEVICE_H
  3. #include <mutex>
  4. #include <string>
  5. #include <vector>
  6. #include "Util/Timer.h"
  7. #include "Util/HttpClient.h"
  8. namespace PresenceDetection {
  9. namespace UniFi {
  10. class Device
  11. {
  12. public:
  13. Device(const std::string& hostname, const std::string& username, const std::string& password, const std::string& cookieFile, const std::string& target);
  14. ~Device();
  15. void Start();
  16. void Stop();
  17. void Wait();
  18. private:
  19. bool Login();
  20. void Logout();
  21. void UpdatePresentDevices();
  22. private:
  23. Util::Timer m_timer;
  24. Util::HttpClient m_httpClient;
  25. std::mutex m_mutex;
  26. bool m_loggedIn;
  27. std::string m_hostname;
  28. std::string m_username;
  29. std::string m_password;
  30. std::string m_cookieFile;
  31. std::string m_target;
  32. int m_offlineTimeout;
  33. std::vector<std::string> m_presentDevices;
  34. };
  35. } // namespace UniFi
  36. } // namespace PresenceDetection
  37. #endif // UNIFI_DEVICE_H