Implement simple websocket client

This commit is contained in:
Vitaliy Filippov
2020-04-25 23:11:50 +03:00
parent 35481925b1
commit 268b497c0b
6 changed files with 553 additions and 314 deletions
+17 -2
View File
@@ -2,7 +2,13 @@
#include <string>
#include <vector>
#include <map>
#include "json11/json11.hpp"
#define WS_CONTINUATION 0
#define WS_TEXT 1
#define WS_BINARY 2
#define WS_CLOSE 8
#define WS_PING 9
#define WS_PONG 10
struct http_response_t
{
@@ -11,9 +17,18 @@ struct http_response_t
int status_code = 0;
std::string status_line;
std::map<std::string, std::string> headers;
int ws_msg_type = -1;
std::string body;
};
void parse_headers(std::string & res, http_response_t *parsed);
struct http_co_t;
struct websocket_t
{
http_co_t *co;
void post_message(int type, const std::string & msg);
};
void parse_http_headers(std::string & res, http_response_t *parsed);
std::vector<std::string> getifaddr_list(bool include_v6 = false);
uint64_t stoull_full(const std::string & str, int base = 10);