NASFAQ/connections/ws/http_handshake.cpp
2022-12-10 15:35:16 +01:00

30 lines
928 B
C++

#include "http_handshake.h"
namespace ws {
namespace http_handshake {
std::string get_sid() {
static const char *POLLING_URL_0 = "https://nasfaq.biz/socket/?EIO=4&transport=polling&t=Ny7z439";
static const char *POLLING_URL_1 = "https://nasfaq.biz/socket/?user=314d0bda-d7f0-4636-aed7-5ea02743604b&EIO=4&transport=polling&t=Ny7z472";
static const char *POLLING_URL_2 = "https://nasfaq.biz/socket/?user=314d0bda-d7f0-4636-aed7-5ea02743604b&EIO=4&transport=polling&t=Ny7z4Bn&sid=";
nlohmann::json json_ret;
std::string sid;
nsfq_http::http_connector::connector c;
/* Start handshake, first result is discarded. */
c.get(POLLING_URL_0);
c.get(POLLING_URL_1);
/* Get session id for websocket. */
json_ret = nlohmann::json::parse(c.get_buffer().substr(1));
sid = json_ret["sid"];
/* Post "40" acknowledgement with sid. */
c.post(POLLING_URL_2 + sid, "40");
return sid;
}
}
}