123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- #ifndef HTTPSCOKET
- #define HTTPSCOKET
- #include "funall.h"
- using namespace std;
- class IIhttpsocket
- {
- public:
- function<void(weblib::httpinfo, function<void(string&, int)>&&)> m_gamemsg{ nullptr };
- function<void(string, boost::any)> m_updatestatic{ nullptr };
- function<void(function<void()>&&)> m_postmsg{ nullptr };
- function<void(string)> m_writelog{ nullptr };
- public:
- virtual void init() = 0;
- virtual bool postmsg(function<void(string&, int)> funhttpmsg, map<string, string> getdata) = 0;
- virtual void updatemsg(string strtype, boost::any getdata) = 0;
- };
- class HttpSocket :public IIhttpsocket
- {
- typedef function<string(map<string, string> getdata)> funcmsg;
- protected:
- unordered_map<int32_t, string> m_maparead;
- unordered_map<int64_t, string> m_mapuseridname;
- unordered_map<int64_t, unordered_set<string>> m_mapipwhite;
- default_random_engine m_random;
- string m_strshahead;
- string m_strshaheadcontent;
- void* m_psendhttp;
- uint32_t m_ucurid;
- //接受http消息
- boost::shared_ptr<boost::asio::deadline_timer> data_time;
- boost::shared_ptr <boost::asio::io_context> m_pmsgservice;
- boost::shared_ptr <boost::asio::io_context::work> m_pmsgwork;
- map<uint32_t, funcmsg> m_callmsg;
- bool m_brun;
- thread m_msgthread;
- //用户信息
- protected:
- boost::shared_ptr<mongocxx::uri> m_puri;
- boost::shared_ptr<mongocxx::client> m_pclient;
- //索引集合
- boost::shared_ptr<mongocxx::collection> m_pallindex;
- // 用户数据库
- boost::shared_ptr<mongocxx::database> m_pdb;
- // 平台数据库
- boost::shared_ptr<mongocxx::database> m_platform;
- // 日志库
- boost::shared_ptr<mongocxx::database> m_gamelog;
- // task库
- boost::shared_ptr<mongocxx::database> m_ptask;
- // 推广数据库
- boost::shared_ptr<mongocxx::database> m_pvipuserdb;
- // 代理日志库
- boost::shared_ptr<mongocxx::database> m_viplog;
- // webdata数据库
- boost::shared_ptr<mongocxx::database> m_webdata;
- // 集合
- boost::shared_ptr<mongocxx::collection> m_pcoll;
- //用户在线集合
- boost::shared_ptr<mongocxx::collection> m_pplayuseronline;
- //用户登录集合
- boost::shared_ptr<mongocxx::collection> m_userloginonline;
- //输赢集合
- boost::shared_ptr<mongocxx::collection> m_plosewincoll;
- //推广集合
- boost::shared_ptr<mongocxx::collection> m_pvipuser;
- //转分集合
- boost::shared_ptr<mongocxx::collection> m_pusertradeinfo;
- //转分集合
- boost::shared_ptr<mongocxx::collection> m_pviptradeinfo;
- //下载日志集合
- boost::shared_ptr<mongocxx::collection> m_puserdowninfo;
- //操作日志集合
- boost::shared_ptr<mongocxx::collection> m_poperatinfo;
- //vip日志统计表
- boost::shared_ptr<mongocxx::collection> m_pgameviploginfo;
- boost::shared_ptr<mongocxx::collection> m_pgameserverloginfo;
- //总代日志统计临时表
- boost::shared_ptr<mongocxx::collection> m_pvipalllogcache;
- //房间统计临时表
- boost::shared_ptr<mongocxx::collection> m_pserverlogcache;
- //用户输赢计临时表
- boost::shared_ptr<mongocxx::collection> m_puserlogcache;
- //商户日志统计临时表
- boost::shared_ptr<mongocxx::collection> m_pviplogcache;
- //玩家日志统计表
- boost::shared_ptr<mongocxx::collection> m_pgameuserloginfo;
- //全部日志
- boost::shared_ptr<mongocxx::collection> m_pgameprizelog;
- //商家卖收分
- boost::shared_ptr<mongocxx::collection> m_pvipscore;
- //商家卖收分
- boost::shared_ptr<mongocxx::collection> m_pvipscoredate;
- //推广账号
- boost::shared_ptr<mongocxx::collection> m_pvipuseraccounts;
- //玩家每天日志信息
- boost::shared_ptr<mongocxx::collection> m_puserdatainfo;
- //商家配置表
- boost::shared_ptr<mongocxx::collection> m_pvipconfigure;
- //商家子账号表
- boost::shared_ptr<mongocxx::collection> m_pusersub;
- //汇率配置表
- boost::shared_ptr<mongocxx::collection> m_pexechangerate;
- //游戏房间表
- boost::shared_ptr<mongocxx::collection> m_pkinditem;
- //管理员api
- boost::shared_ptr<mongocxx::collection> m_pthreeadmin;
- //任务配置表
- boost::shared_ptr<mongocxx::collection> m_pconfig;
- //设置白名单
- boost::shared_ptr<mongocxx::collection> m_pipwhite;
- //设置转账和无缝申请
- boost::shared_ptr<mongocxx::collection> m_papplyviplog;
- //vip留言日志
- boost::shared_ptr<mongocxx::collection> m_pvipmsglog;
- //游戏配置表
- boost::shared_ptr<mongocxx::collection> m_pgamelist;
- //游戏gamegameitem
- boost::shared_ptr<mongocxx::collection> m_pgamegameitem;
- //推广网站信息
- boost::shared_ptr<mongocxx::collection> m_ppopularizesit;
- //信用代理-跑马灯
- boost::shared_ptr<mongocxx::collection> m_pmarquee;
- //信用代理-联系客服
- boost::shared_ptr<mongocxx::collection> m_pcustomerlink;
- //信用代理-topwinner
- boost::shared_ptr<mongocxx::collection> m_pcredittopwinner;
- // 活动
- boost::shared_ptr<mongocxx::collection> m_activityfreegame;
- // 重发订单
- boost::shared_ptr<mongocxx::collection> m_resendorder;
- //货币游戏排序
- boost::shared_ptr<mongocxx::collection> m_pareagames;
- // playrecordini
- boost::shared_ptr<mongocxx::collection> m_pplayrecordini;
- // 游戏投注配置
- boost::shared_ptr<mongocxx::collection> m_pgamebet;
- // activityini
- boost::shared_ptr<mongocxx::collection> m_pactivityini;
- // webserver 平台类型
- boost::shared_ptr<mongocxx::collection> m_pplatformini;
- // thirdplat 第3方厂商管理
- boost::shared_ptr<mongocxx::collection> m_pthirddeveloper;
- // thirdplat 第3方厂商游戏
- boost::shared_ptr<mongocxx::collection> m_pthirdgames;
- public:
- HttpSocket();
- ~HttpSocket();
- virtual void init();
- virtual bool postmsg(function<void(string&, int)> funhttpmsg, map<string, string> getdata) { return true;};
- virtual void updatemsg(string strtype, boost::any getdata) {};
- void stopmsg() {};
- public:
- void sendreelmsg(string stronly, string strtarget, string strjson, function<void(string, int)>&& dofun);
- //更新拉取时间
- void setsynctime(__int64 itimefrom, __int64 intimeto, __int32 page, bool bdone);
- void getsynctime(__int64& itimefrom, __int64& intimeto, __int32& page, bool& bdone);
- //拉取日志
- void getgamehistory(__int64 dataFrom, __int64 dataTo, __int32 ifirstpage);
- };
-
- ////////////////////////////////////JsonToBson//////////////////////////////////////
- void convertJsonToBson(bsoncxx::builder::basic::document& doc, const rapidjson::Value& jsonValue);
- void convertJsonValueToBson(bsoncxx::builder::basic::array& arr, const rapidjson::Value& jsonValue);
- void handleArray(bsoncxx::builder::basic::document& doc, const string& key, const rapidjson::Value& arrayValue);
- ////////////////////////////////////JsonToBson End//////////////////////////////////////
- #endif
|