| | |
| | | #include <string> |
| | | #include <unordered_map> |
| | | |
| | | using namespace std::literals; |
| | | |
| | | namespace protocol |
| | | { |
| | | static std::unordered_map<json::MessageTypes, book::ProductTypeEnum> |
| | | mapAnnounce; |
| | | std::string server = std::string(HOST) + ":" + std::string(PORT); |
| | | httplib::Client cli("http://" + server); |
| | | #define SERVER HOST ":" PORT |
| | | httplib::Client cli("http://" SERVER); |
| | | std::unique_ptr<easywsclient::WebSocket> ws; |
| | | |
| | | double lastime = 0; |
| | |
| | | // std::ifstream sampleFile("../data.test"); |
| | | // std::stringstream ss; |
| | | // ss << sampleFile.rdbuf(); |
| | | httplib::Client cli("http://" + server); |
| | | auto res = cli.Get("/recover"); |
| | | std::string l; |
| | | // l = ss.str(); |
| | |
| | | void createWebSocket() |
| | | { |
| | | ws = std::unique_ptr<easywsclient::WebSocket>( |
| | | easywsclient::WebSocket::pointer(easywsclient::WebSocket::from_url( |
| | | "ws://" + server + "/information"))); |
| | | easywsclient::WebSocket::pointer( |
| | | easywsclient::WebSocket::from_url("ws://" SERVER "/information"))); |
| | | ws->poll(); |
| | | } |
| | | |
| | |
| | | httplib::MultipartFormDataItems a = {{"message", message, "", ""}, |
| | | {"username", USER, "", ""}, |
| | | {"password", PASS, "", ""}}; |
| | | auto res = cli.Post("/execution", |
| | | "message=" + message + "&username=" + USER + |
| | | "&password=" + PASS, |
| | | "application/x-www-form-urlencoded"); |
| | | auto res = |
| | | cli.Post("/execution", |
| | | "message=" + message + "&username=" USER "&password=" PASS, |
| | | "application/x-www-form-urlencoded"); |
| | | std::string b = res->body; |
| | | std::queue<json::Message*> c = json::parse(b); |
| | | return c.front(); |