SendLogin.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #pragma once
  2. #include <iostream>
  3. #include <rapidjson/document.h>
  4. #include <rapidjson/rapidjson.h>
  5. #include <rapidjson/stringbuffer.h>
  6. #include <rapidjson/writer.h>
  7. using namespace std;
  8. class SendLogin
  9. {
  10. private:
  11. /* data */
  12. // 客户端分配的帐号
  13. string account;
  14. // 给客户端的密码
  15. string pwd;
  16. // 给客户端分配的token,可为空
  17. string token;
  18. // 该连接关联的相机IP
  19. string cameraIp;
  20. // 工控机sim码,唯一标识
  21. std::string simCode;
  22. // 扩展数据
  23. // 约定为对应相机设备的基本信息,用户名、密码、ip、端口、码流;设备种类、设备类型可不必填,设置默认值;设备编号、设备名称后台随机生成
  24. // {"localIp":"xx","deviceUserName":"xx","devicePassWord":"xx","port":"xx","stream":"xx"}
  25. string attr1;
  26. string attr2;
  27. string attr3;
  28. public:
  29. SendLogin(){}
  30. ~SendLogin(){}
  31. void setAccount(string Account){
  32. account = Account;
  33. }
  34. void setPwd(string Pwd){
  35. pwd = Pwd;
  36. }
  37. void setToken(string Token){
  38. token = Token;
  39. }
  40. void setCameraIp(string CameraIp){
  41. cameraIp = CameraIp;
  42. }
  43. void setAttr1(string Attr1){
  44. attr1 = Attr1;
  45. }
  46. void setAttr2(string Attr2){
  47. attr2 = Attr2;
  48. }
  49. void setAttr3(string Attr3){
  50. attr3 = Attr3;
  51. }
  52. void setSimCode(std::string SimCode){
  53. simCode = SimCode;
  54. }
  55. string getAccount(){
  56. return account;
  57. }
  58. string getPwd(){
  59. return pwd;
  60. }
  61. string getToken(){
  62. return token;
  63. }
  64. string getCameraIp(){
  65. return cameraIp;
  66. }
  67. string getAttr1(){
  68. return attr1;
  69. }
  70. string getAttr2(){
  71. return attr2;
  72. }
  73. string getAttr3(){
  74. return attr3;
  75. }
  76. string getSimCode(){
  77. return simCode;
  78. }
  79. void objectToJson(string& str){
  80. rapidjson::StringBuffer strBuf;
  81. rapidjson::Writer<rapidjson::StringBuffer> writer(strBuf);
  82. this->objectToJson(writer);
  83. str = strBuf.GetString();
  84. }
  85. void objectToJson(rapidjson::Writer<rapidjson::StringBuffer>& writer){
  86. writer.StartObject();
  87. writer.Key("account");
  88. writer.String(account.c_str());
  89. writer.Key("pwd");
  90. writer.String(pwd.c_str());
  91. writer.Key("token");
  92. writer.String(token.c_str());
  93. writer.Key("cameraIp");
  94. writer.String(cameraIp.c_str());
  95. writer.Key("simCode");
  96. writer.String(simCode.c_str());
  97. writer.Key("attr1");
  98. writer.String(attr1.c_str());
  99. writer.Key("attr2");
  100. writer.String(attr2.c_str());
  101. writer.Key("attr3");
  102. writer.String(attr3.c_str());
  103. writer.EndObject();
  104. }
  105. bool JsonToObject(){
  106. return true;
  107. }
  108. };