1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- #ifndef MODULE_WEB_H
- #define MODULE_WEB_H
- #include <memory>
- #include <string>
- #include"module_const.h"
- #include "rapidjson/prettywriter.h"
- #include "rapidjson/document.h"
- #include "websocket/wsClientMgr.h"
- class module_web : public i_thread, public singleton_base<module_web>
- {
- private:
- friend class singleton_base<module_web>;
- module_web()
- {
- }
- public:
-
- static void accept( int ID, std::string const& name,
- sio::message::ptr const& data, bool need_ack, sio::message::list &ack_resp );
-
- void init(config_file& config, std::map<std::string, YA::MSG_HANDLE_FUNC_TYPE>& MsgFuncList)
- {
- sleep_ms = std::stoi(config.get("interval_send_json_alarm","10000"));
- MsgFuncList.insert( std::make_pair( JSON_CMD_VALUE_REQUEST_ALL_DATA, &module_web::accept ) );
- MsgFuncList.insert( std::make_pair( JSON_CMD_VALUE_DEAL_HELP, &module_web::accept ) );
- MsgFuncList.insert( std::make_pair( JSON_CMD_VALUE_CALL_CARD_REQUEST, &module_web::accept ) );
- MsgFuncList.insert( std::make_pair( JSON_CMD_VALUE_CALL_CARD_CANCEL_REQUEST, &module_web::accept ) );
- MsgFuncList.insert( std::make_pair( JSON_CMD_VALUE_CLEAR_CARD, &module_web::accept ) );
- }
-
- void response_login();
- private:
-
- void run();
-
- void get_all_events(std::vector<std::shared_ptr<ya_event>>& arr)
- {
- auto _map = event_list::instance()->m_map;
- auto it_map = _map.begin();
- for(;it_map!=_map.end();++it_map)
- {
- arr.push_back(it_map->second);
- }
- }
-
- void delete_end(std::vector<std::shared_ptr<ya_event>>& arr)
- {
- std::vector<uint64_t> todelete;
- auto arr_iter = arr.begin();
- for(;arr_iter!=arr.end();++arr_iter)
- {
- if((*arr_iter)->is_end())
- {
- todelete.push_back((*arr_iter)->get_list_id());
- }
- }
- if(todelete.size())
- {
- event_list::instance()->remove(todelete);
- }
- }
- };
- #endif
|