diff options
-rw-r--r-- | protocols/Discord/src/connection.cpp | 18 | ||||
-rw-r--r-- | protocols/Discord/src/dispatch.cpp | 2 |
2 files changed, 13 insertions, 7 deletions
diff --git a/protocols/Discord/src/connection.cpp b/protocols/Discord/src/connection.cpp index 7a7fb306a9..3b82e4112b 100644 --- a/protocols/Discord/src/connection.cpp +++ b/protocols/Discord/src/connection.cpp @@ -74,10 +74,8 @@ void CDiscordProto::OnLoggedOut() { debugLogA("CDiscordProto::OnLoggedOut"); m_bOnline = false; - m_hWorkerThread = NULL; - - if (m_hAPIConnection) - Netlib_CloseHandle(m_hAPIConnection); + m_bTerminated = true; + m_iGatewaySeq = 0; ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)m_iStatus, ID_STATUS_OFFLINE); m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; @@ -85,11 +83,19 @@ void CDiscordProto::OnLoggedOut() void CDiscordProto::ShutdownSession() { + if (m_bTerminated) + return; + debugLogA("CDiscordProto::ShutdownSession"); - m_bTerminated = true; - m_iGatewaySeq = 0; + + // shutdown all resources if (m_hWorkerThread) SetEvent(m_evRequestsQueue); + if (m_hGatewayConnection) + Netlib_Shutdown(m_hGatewayConnection); + if (m_hAPIConnection) + Netlib_Shutdown(m_hAPIConnection); + OnLoggedOut(); } diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp index 0cb74c06a3..a2f0320b08 100644 --- a/protocols/Discord/src/dispatch.cpp +++ b/protocols/Discord/src/dispatch.cpp @@ -168,7 +168,7 @@ void CDiscordProto::OnCommandReady(const JSONNode &pRoot) SnowFlake oldMsgId = getId(pUser->hContact, DB_KEY_LASTMSGID); if (pUser->lastMessageId > oldMsgId) - RetrieveHistory(pUser->hContact, MSG_AFTER, oldMsgId); + RetrieveHistory(pUser->hContact, MSG_AFTER, oldMsgId, 99); } } |