mirror of
https://github.com/celisej567/abaddon.git
synced 2025-12-31 17:48:26 +03:00
HeartbeatMessage now uses yyjson
This commit is contained in:
@@ -2658,8 +2658,8 @@ void DiscordClient::HeartbeatThread() {
|
||||
|
||||
HeartbeatMessage msg;
|
||||
msg.Sequence = m_last_sequence;
|
||||
nlohmann::json j = msg;
|
||||
m_websocket.Send(j);
|
||||
//nlohmann::json j = msg;
|
||||
m_websocket.Send(msg.BuildJson());
|
||||
|
||||
if (!m_heartbeat_waiter.wait_for(std::chrono::milliseconds(m_heartbeat_msec)))
|
||||
break;
|
||||
|
||||
@@ -517,6 +517,19 @@ struct IdentifyMessage : GatewayMessage {
|
||||
struct HeartbeatMessage : GatewayMessage {
|
||||
int Sequence;
|
||||
|
||||
std::string BuildJson() const
|
||||
{
|
||||
YYJsonDocument yyjsn;
|
||||
yyjsn.CreateDoc();
|
||||
yyjsn.AddInt("op", (int)GatewayOp::Heartbeat);
|
||||
if (Sequence == -1)
|
||||
yyjsn.AddNull("d");
|
||||
else
|
||||
yyjsn.AddInt("d", Sequence);
|
||||
|
||||
return yyjsn.BuildJson();
|
||||
}
|
||||
|
||||
friend void to_json(nlohmann::json &j, const HeartbeatMessage &m);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user