diff options
author | George Hazan <ghazan@miranda.im> | 2020-03-23 22:26:26 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-03-23 22:26:26 +0300 |
commit | 01f025838429b746205f4d1f46b46a9acfac8848 (patch) | |
tree | 9c7fb20c73741d4e276f8c74008b5097600ceee1 /protocols/Discord/src | |
parent | c3e56141b7996b34e776054dd6a8144594363428 (diff) |
Discord: opcode 7 processing added
Diffstat (limited to 'protocols/Discord/src')
-rw-r--r-- | protocols/Discord/src/gateway.cpp | 10 | ||||
-rw-r--r-- | protocols/Discord/src/proto.h | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/protocols/Discord/src/gateway.cpp b/protocols/Discord/src/gateway.cpp index 5dfcea52f5..eccf8aea90 100644 --- a/protocols/Discord/src/gateway.cpp +++ b/protocols/Discord/src/gateway.cpp @@ -120,7 +120,7 @@ bool CDiscordProto::GatewayThreadWorker() debugLogA("JSON received:\n%s", szJson.c_str()); JSONNode root = JSONNode::parse(szJson); if (root) - GatewayProcess(root); + bExit = GatewayProcess(root); } break; @@ -168,7 +168,7 @@ bool CDiscordProto::GatewayThreadWorker() ////////////////////////////////////////////////////////////////////////////////////// // handles server commands -void CDiscordProto::GatewayProcess(const JSONNode &pRoot) +bool CDiscordProto::GatewayProcess(const JSONNode &pRoot) { int opCode = pRoot["op"].as_int(); switch (opCode) { @@ -187,6 +187,10 @@ void CDiscordProto::GatewayProcess(const JSONNode &pRoot) } break; + case OPCODE_RECONNECT: // we need to reconnect asap + debugLogA("we need to reconnect, leaving worker thread"); + return true; + case OPCODE_INVALID_SESSION: // session invalidated if (pRoot["d"].as_bool()) // session can be resumed GatewaySendResume(); @@ -208,6 +212,8 @@ void CDiscordProto::GatewayProcess(const JSONNode &pRoot) default: debugLogA("ACHTUNG! Unknown opcode: %d, report it to developer", opCode); } + + return false; } ////////////////////////////////////////////////////////////////////////////////////// diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h index 105b1368fc..1fd77e06f1 100644 --- a/protocols/Discord/src/proto.h +++ b/protocols/Discord/src/proto.h @@ -231,7 +231,7 @@ class CDiscordProto : public PROTO<CDiscordProto> bool GatewayThreadWorker(void); void GatewaySend(const JSONNode &pNode); - void GatewayProcess(const JSONNode &pNode); + bool GatewayProcess(const JSONNode &pNode); void GatewaySendHeartbeat(void); void GatewaySendIdentify(void); |