HttpSocket.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #ifndef HTTPSCOKET
  2. #define HTTPSCOKET
  3. #include "funall.h"
  4. #include "webfun.h"
  5. class IIhttpsocket
  6. {
  7. public:
  8. std::function<void(weblib::httpinfo, std::function<void(std::string&, int)>&&)> m_gamemsg{ nullptr };
  9. std::function<void(std::string, boost::any)> m_updatestatic{ nullptr };
  10. std::function<void(std::function<void()>&&)> m_postmsg{ nullptr };
  11. std::function<void(std::string)> m_writelog{ nullptr };
  12. public:
  13. virtual void init() = 0;
  14. virtual bool postmsg(std::function<void(std::string&, int)> funhttpmsg, std::map<std::string, std::string> getdata) = 0;
  15. virtual void updatemsg(std::string strtype, boost::any getdata) = 0;
  16. };
  17. class HttpSocket:public IIhttpsocket
  18. {
  19. typedef std::function<std::string(std::map<std::string, std::string> getdata)> funcmsg;
  20. protected:
  21. bsoncxx::builder::basic::array m_useridarray;
  22. std::unordered_map<std::int64_t, std::string> m_mapuseridname;
  23. std::default_random_engine m_random;
  24. std::string m_strshahead;
  25. std::string m_strshaheadcontent;
  26. void* m_psendhttp;
  27. static std::uint32_t m_gucurid;
  28. std::uint32_t m_ucurid;
  29. //接受http消息
  30. std::map<std::string, funcmsg> m_callmsg;
  31. staticdata m_staticdata;
  32. //用户信息
  33. protected:
  34. boost::shared_ptr<mongocxx::uri> m_puri;
  35. boost::shared_ptr<mongocxx::client> m_pclient;
  36. //索引集合
  37. boost::shared_ptr<mongocxx::collection> m_pallindex;
  38. // 用户数据库
  39. boost::shared_ptr<mongocxx::database> m_pdb;
  40. // 日志库
  41. boost::shared_ptr<mongocxx::database> m_gamelog;
  42. // 推广数据库
  43. boost::shared_ptr<mongocxx::database> m_pvipuserdb;
  44. // 集合
  45. boost::shared_ptr<mongocxx::collection> m_pcoll;
  46. //用户在线集合
  47. boost::shared_ptr<mongocxx::collection> m_pplayuseronline;
  48. //用户登录集合
  49. boost::shared_ptr<mongocxx::collection> m_userloginonline;
  50. //输赢集合
  51. boost::shared_ptr<mongocxx::collection> m_plosewincoll;
  52. //游戏每局奖励记录
  53. boost::shared_ptr<mongocxx::collection> m_pgameprizelog;
  54. //推广集合
  55. boost::shared_ptr<mongocxx::collection> m_pvipuser;
  56. //转分集合
  57. boost::shared_ptr<mongocxx::collection> m_pusertradeinfo;
  58. //转分集合
  59. boost::shared_ptr<mongocxx::collection> m_pviptradeinfo;
  60. //操作日志集合
  61. boost::shared_ptr<mongocxx::collection> m_poperatinfo;
  62. //商家卖收分
  63. boost::shared_ptr<mongocxx::collection> m_pvipscore;
  64. //商家卖收分
  65. boost::shared_ptr<mongocxx::collection> m_pvipscoredate;
  66. //推广账号
  67. boost::shared_ptr<mongocxx::collection> m_pvipuseraccounts;
  68. //玩家每天日志信息
  69. boost::shared_ptr<mongocxx::collection> m_puserdatainfo;
  70. //第三方平台
  71. boost::shared_ptr<mongocxx::collection> m_pthreeadmin;
  72. //商家配置表
  73. boost::shared_ptr<mongocxx::collection> m_pvipconfigure;
  74. // 平台库
  75. boost::shared_ptr<mongocxx::database> m_platform;
  76. //游戏配置表
  77. boost::shared_ptr<mongocxx::collection> m_pgamelist;
  78. //三方转账记录
  79. boost::shared_ptr<mongocxx::collection> m_pthirdtranslog;
  80. // thirdplat 第3方厂商管理
  81. boost::shared_ptr<mongocxx::collection> m_pthirddeveloper;
  82. // 兑换码
  83. boost::shared_ptr<mongocxx::collection> m_predeemcode;
  84. public:
  85. HttpSocket();
  86. ~HttpSocket();
  87. void stopmsg();
  88. std::string getuseraccount(std::int32_t iregion);
  89. void makegamelist(staticdata& tstaticdata);
  90. void init();
  91. bool postmsg(std::function<void(std::string&, int)> funhttpmsg, std::map<std::string, std::string> getdata);
  92. void updatemsg(std::string strtype, boost::any getdata);
  93. protected:
  94. //获得游戏列表
  95. std::string getgamelist(std::map<std::string, std::string> getdata);
  96. //玩家账号注册
  97. std::string regaccount(std::map<std::string, std::string> getdata);
  98. //玩家更新分数
  99. std::string updateuserscore(std::map<std::string, std::string> getdata, std::function<void(std::string&, int)>& dofun);
  100. //把玩家踢出游戏
  101. std::string adminhituser(std::map<std::string, std::string> getdata, std::function<void(std::string&, int)>& dofun);
  102. //管理员禁止管理员所属玩家
  103. std::string adminforbiduser(std::map<std::string, std::string> getdata);
  104. //获取账号
  105. std::string getuseraccount(std::map<std::string, std::string> getdata);
  106. //修改下级玩家信息
  107. std::string modifyuserinfo(std::map<std::string, std::string> getdata);
  108. //管理员禁止自己直属玩家
  109. std::string adminforbidmyuser(std::map<std::string, std::string> getdata);
  110. //查询充值记录
  111. std::string sellbuyinfo(std::map<std::string, std::string> getdata);
  112. //查询游戏每局记录
  113. std::string playgameinfo(std::map<std::string, std::string> getdata);
  114. //获取总赌注和总输赢
  115. std::string getuserplayscoreinfo(std::map<std::string, std::string> getdata);
  116. //添加奖励码
  117. std::string updateuseringot(std::map<std::string, std::string> getdata);
  118. //回退奖励码
  119. std::string backuseringot(std::map<std::string, std::string> getdata);
  120. //获取所有总赌注和总输赢
  121. std::string getalluserplayscoreinfo(std::map<std::string, std::string> getdata);
  122. //-------------------------------真人视讯-----------------------------------------
  123. //登录真人视讯
  124. std::string reelplay(std::map<std::string, std::string> getdata, std::function<void(std::string&, int)>& dofun);
  125. void sendreelmsg(std::string stronly, std::string strtarget, std::string strjson, std::function<void(std::string, int)>&& dofun);
  126. //创建玩家
  127. void createreeluser(std::string struseracc, __int32 ikindid, std::int64_t iscore, __int64 iuserid, std::function<void(std::string&, int)> dofun);
  128. //玩家转账到三方
  129. void reelusertrans(std::string struseracc, __int32 ikindid, std::int64_t iscore, __int64 iuserid, std::function<void(std::string&, int)> dofun);
  130. bool updateusertrans(std::string struseracc, __int32 ikindid, std::string strtransid, std::int64_t iscore);
  131. //拉取游戏
  132. void getreelgameurl(std::string struseracc, __int32 ikindid, __int64 iuserid, std::function<void(std::string&, int)> dofun);
  133. //-------------------------------兑换码---------------------------------------
  134. std::string generateredeemcodes(std::map<std::string, std::string> getdata);
  135. };
  136. #endif