linux版本中间件

Config.h 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #pragma once
  2. #include <string>
  3. #include <memory>
  4. #include <json/json.h>
  5. #define CFGPATH "cfg.json"
  6. class CConfig
  7. {
  8. public:
  9. ~CConfig();
  10. bool load();
  11. // freeswitch属性
  12. std::string fsIp() const { return m_fsIp; }
  13. std::int16_t fsPort() const { return m_fsPort; }
  14. std::string fsPwd() const { return m_fsPwd; }
  15. // websocket属性
  16. std::int16_t wsPort()const { return m_wsPort; }
  17. std::int16_t wssPort()const { return m_wssPort; }
  18. std::string sslFile()const { return m_sslFilePath; }
  19. std::string sslPwd()const { return m_sslPwd; }
  20. // 数据库属性
  21. std::string dbHost()const { return m_DBhost; }
  22. std::string dbUser()const { return m_DBusername; }
  23. std::string dbPwd()const { return m_DBpasswd; }
  24. std::string dbName()const { return m_DBdatabase; }
  25. static std::shared_ptr<CConfig> GetInstance() { return pInstance; }
  26. private:
  27. CConfig();
  28. CConfig(const CConfig&) = default;
  29. CConfig& operator=(const CConfig&) = default;
  30. bool write();
  31. private:
  32. // FreeSWITCH 连接信息
  33. std::string m_fsIp; // freeSwitch ip
  34. std::int16_t m_fsPort; // freeswitch 端口
  35. std::string m_fsPwd; // freeswitch 密码
  36. // websocket 信息
  37. std::int16_t m_wsPort; // websocket ws端口
  38. std::int16_t m_wssPort; // websocket wss端口
  39. std::string m_sslFilePath; // ssl 证书
  40. std::string m_sslPwd; // SSL 证书密码
  41. // 数据库信息
  42. std::string m_DBhost;
  43. std::string m_DBusername;
  44. std::string m_DBpasswd;
  45. std::string m_DBdatabase;
  46. Json::Value root;
  47. static std::shared_ptr<CConfig> pInstance;
  48. };