summaryrefslogtreecommitdiff
path: root/protocols/Discord
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-01-09 19:15:16 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-01-09 19:15:16 +0300
commitf411d300ca39423ba9fd36e9206b0379fbeb5487 (patch)
tree5895bad492d11f706572f9aabaed6e965cec031b /protocols/Discord
parent86e49c1f6a1f4b978fd700590747c1a03ff7d156 (diff)
fix for issues with connection closing
Diffstat (limited to 'protocols/Discord')
-rw-r--r--protocols/Discord/src/connection.cpp18
-rw-r--r--protocols/Discord/src/dispatch.cpp2
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);
}
}