HttpSocket.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. #ifndef HTTPSCOKET
  2. #define HTTPSCOKET
  3. #include "funall.h"
  4. using namespace std;
  5. class IIhttpsocket
  6. {
  7. public:
  8. function<void(weblib::httpinfo, function<void(string&, int)>&&)> m_gamemsg{ nullptr };
  9. function<void(string, boost::any)> m_updatestatic{ nullptr };
  10. function<void(function<void()>&&)> m_postmsg{ nullptr };
  11. function<void(string)> m_writelog{ nullptr };
  12. public:
  13. virtual void init() = 0;
  14. virtual bool postmsg(function<void(string&, int)> funhttpmsg, map<string, string> getdata) = 0;
  15. virtual void updatemsg(string strtype, boost::any getdata) = 0;
  16. };
  17. class HttpSocket :public IIhttpsocket
  18. {
  19. typedef function<string(map<string, string> getdata)> funcmsg;
  20. protected:
  21. unordered_map<int32_t, string> m_maparead;
  22. unordered_map<int64_t, string> m_mapuseridname;
  23. unordered_map<int64_t, unordered_set<string>> m_mapipwhite;
  24. default_random_engine m_random;
  25. string m_strshahead;
  26. string m_strshaheadcontent;
  27. void* m_psendhttp;
  28. uint32_t m_ucurid;
  29. //接受http消息
  30. boost::shared_ptr<boost::asio::deadline_timer> data_time;
  31. boost::shared_ptr <boost::asio::io_context> m_pmsgservice;
  32. boost::shared_ptr <boost::asio::io_context::work> m_pmsgwork;
  33. map<uint32_t, funcmsg> m_callmsg;
  34. bool m_brun;
  35. thread m_msgthread;
  36. //用户信息
  37. protected:
  38. boost::shared_ptr<mongocxx::uri> m_puri;
  39. boost::shared_ptr<mongocxx::client> m_pclient;
  40. //索引集合
  41. boost::shared_ptr<mongocxx::collection> m_pallindex;
  42. // 用户数据库
  43. boost::shared_ptr<mongocxx::database> m_pdb;
  44. // 平台数据库
  45. boost::shared_ptr<mongocxx::database> m_platform;
  46. // 日志库
  47. boost::shared_ptr<mongocxx::database> m_gamelog;
  48. // task库
  49. boost::shared_ptr<mongocxx::database> m_ptask;
  50. // 推广数据库
  51. boost::shared_ptr<mongocxx::database> m_pvipuserdb;
  52. // 代理日志库
  53. boost::shared_ptr<mongocxx::database> m_viplog;
  54. // webdata数据库
  55. boost::shared_ptr<mongocxx::database> m_webdata;
  56. // 集合
  57. boost::shared_ptr<mongocxx::collection> m_pcoll;
  58. //用户在线集合
  59. boost::shared_ptr<mongocxx::collection> m_pplayuseronline;
  60. //用户登录集合
  61. boost::shared_ptr<mongocxx::collection> m_userloginonline;
  62. //输赢集合
  63. boost::shared_ptr<mongocxx::collection> m_plosewincoll;
  64. //推广集合
  65. boost::shared_ptr<mongocxx::collection> m_pvipuser;
  66. //转分集合
  67. boost::shared_ptr<mongocxx::collection> m_pusertradeinfo;
  68. //转分集合
  69. boost::shared_ptr<mongocxx::collection> m_pviptradeinfo;
  70. //下载日志集合
  71. boost::shared_ptr<mongocxx::collection> m_puserdowninfo;
  72. //操作日志集合
  73. boost::shared_ptr<mongocxx::collection> m_poperatinfo;
  74. //vip日志统计表
  75. boost::shared_ptr<mongocxx::collection> m_pgameviploginfo;
  76. boost::shared_ptr<mongocxx::collection> m_pgameserverloginfo;
  77. //总代日志统计临时表
  78. boost::shared_ptr<mongocxx::collection> m_pvipalllogcache;
  79. //房间统计临时表
  80. boost::shared_ptr<mongocxx::collection> m_pserverlogcache;
  81. //用户输赢计临时表
  82. boost::shared_ptr<mongocxx::collection> m_puserlogcache;
  83. //商户日志统计临时表
  84. boost::shared_ptr<mongocxx::collection> m_pviplogcache;
  85. //玩家日志统计表
  86. boost::shared_ptr<mongocxx::collection> m_pgameuserloginfo;
  87. //全部日志
  88. boost::shared_ptr<mongocxx::collection> m_pgameprizelog;
  89. //商家卖收分
  90. boost::shared_ptr<mongocxx::collection> m_pvipscore;
  91. //商家卖收分
  92. boost::shared_ptr<mongocxx::collection> m_pvipscoredate;
  93. //推广账号
  94. boost::shared_ptr<mongocxx::collection> m_pvipuseraccounts;
  95. //玩家每天日志信息
  96. boost::shared_ptr<mongocxx::collection> m_puserdatainfo;
  97. //商家配置表
  98. boost::shared_ptr<mongocxx::collection> m_pvipconfigure;
  99. //商家子账号表
  100. boost::shared_ptr<mongocxx::collection> m_pusersub;
  101. //汇率配置表
  102. boost::shared_ptr<mongocxx::collection> m_pexechangerate;
  103. //游戏房间表
  104. boost::shared_ptr<mongocxx::collection> m_pkinditem;
  105. //管理员api
  106. boost::shared_ptr<mongocxx::collection> m_pthreeadmin;
  107. //任务配置表
  108. boost::shared_ptr<mongocxx::collection> m_pconfig;
  109. //设置白名单
  110. boost::shared_ptr<mongocxx::collection> m_pipwhite;
  111. //设置转账和无缝申请
  112. boost::shared_ptr<mongocxx::collection> m_papplyviplog;
  113. //vip留言日志
  114. boost::shared_ptr<mongocxx::collection> m_pvipmsglog;
  115. //游戏配置表
  116. boost::shared_ptr<mongocxx::collection> m_pgamelist;
  117. //游戏gamegameitem
  118. boost::shared_ptr<mongocxx::collection> m_pgamegameitem;
  119. //推广网站信息
  120. boost::shared_ptr<mongocxx::collection> m_ppopularizesit;
  121. //信用代理-跑马灯
  122. boost::shared_ptr<mongocxx::collection> m_pmarquee;
  123. //信用代理-联系客服
  124. boost::shared_ptr<mongocxx::collection> m_pcustomerlink;
  125. //信用代理-topwinner
  126. boost::shared_ptr<mongocxx::collection> m_pcredittopwinner;
  127. // 活动
  128. boost::shared_ptr<mongocxx::collection> m_activityfreegame;
  129. // 重发订单
  130. boost::shared_ptr<mongocxx::collection> m_resendorder;
  131. //货币游戏排序
  132. boost::shared_ptr<mongocxx::collection> m_pareagames;
  133. // playrecordini
  134. boost::shared_ptr<mongocxx::collection> m_pplayrecordini;
  135. // 游戏投注配置
  136. boost::shared_ptr<mongocxx::collection> m_pgamebet;
  137. // activityini
  138. boost::shared_ptr<mongocxx::collection> m_pactivityini;
  139. // webserver 平台类型
  140. boost::shared_ptr<mongocxx::collection> m_pplatformini;
  141. // thirdplat 第3方厂商管理
  142. boost::shared_ptr<mongocxx::collection> m_pthirddeveloper;
  143. // thirdplat 第3方厂商游戏
  144. boost::shared_ptr<mongocxx::collection> m_pthirdgames;
  145. public:
  146. HttpSocket();
  147. ~HttpSocket();
  148. virtual void init();
  149. virtual bool postmsg(function<void(string&, int)> funhttpmsg, map<string, string> getdata) { return true;};
  150. virtual void updatemsg(string strtype, boost::any getdata) {};
  151. void stopmsg() {};
  152. public:
  153. void sendreelmsg(string stronly, string strtarget, string strjson, function<void(string, int)>&& dofun);
  154. //更新拉取时间
  155. void setsynctime(__int64 itimefrom, __int64 intimeto, __int32 page, bool bdone);
  156. void getsynctime(__int64& itimefrom, __int64& intimeto, __int32& page, bool& bdone);
  157. //拉取日志
  158. void getgamehistory(__int64 dataFrom, __int64 dataTo, __int32 ifirstpage);
  159. };
  160. ////////////////////////////////////JsonToBson//////////////////////////////////////
  161. void convertJsonToBson(bsoncxx::builder::basic::document& doc, const rapidjson::Value& jsonValue);
  162. void convertJsonValueToBson(bsoncxx::builder::basic::array& arr, const rapidjson::Value& jsonValue);
  163. void handleArray(bsoncxx::builder::basic::document& doc, const string& key, const rapidjson::Value& arrayValue);
  164. ////////////////////////////////////JsonToBson End//////////////////////////////////////
  165. #endif