diff options
author | Robert Pösel <robyer@seznam.cz> | 2015-12-19 22:32:35 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2015-12-19 22:32:35 +0000 |
commit | f795b3b823f76d9c61fccfad53c2f2cfbe5b3115 (patch) | |
tree | 40652761c22bfc3c26982d17b9d7743def399878 /protocols/Steam/src/steam_messages.cpp | |
parent | 02ca3b1dd1a02210333764ebafe7b4dedd68d56e (diff) |
Steam: Use server timestamp for sent messages
git-svn-id: http://svn.miranda-ng.org/main/trunk@15905 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Steam/src/steam_messages.cpp')
-rw-r--r-- | protocols/Steam/src/steam_messages.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/protocols/Steam/src/steam_messages.cpp b/protocols/Steam/src/steam_messages.cpp index 1a51cccb90..f55a31366a 100644 --- a/protocols/Steam/src/steam_messages.cpp +++ b/protocols/Steam/src/steam_messages.cpp @@ -40,6 +40,7 @@ void CSteamProto::OnMessageSent(const HttpResponse *response, void *arg) ptrT error(mir_tstrdup(TranslateT("Unknown error")));
ptrT steamId(getTStringA(param->hContact, "SteamID"));
+ time_t timestamp = NULL;
if (ResponseHttpOk(response))
{
@@ -47,6 +48,10 @@ void CSteamProto::OnMessageSent(const HttpResponse *response, void *arg) JSONNode *node = json_get(root, "error");
if (node)
error = json_as_string(node);
+
+ node = json_get(root, "utc_timestamp");
+ if (node)
+ timestamp = atol(ptrA(mir_t2a(ptrT(json_as_string(node)))));
}
if (mir_tstrcmpi(error, _T("OK")) != 0)
@@ -56,5 +61,28 @@ void CSteamProto::OnMessageSent(const HttpResponse *response, void *arg) ProtoBroadcastAck(param->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, param->hMessage, (LPARAM)errorA);
}
else
+ {
+ // remember server time of this message
+ auto it = m_mpOutMessages.find(param->hMessage);
+ if (it == m_mpOutMessages.end() && timestamp != NULL)
+ m_mpOutMessages[param->hMessage] = timestamp;
+
ProtoBroadcastAck(param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, param->hMessage, 0);
-}
\ No newline at end of file + }
+}
+
+int CSteamProto::OnPreCreateMessage(WPARAM, LPARAM lParam)
+{
+ MessageWindowEvent *evt = (MessageWindowEvent*)lParam;
+ if (mir_strcmp(GetContactProto(evt->hContact), m_szModuleName))
+ return 0;
+
+ auto it = m_mpOutMessages.find((HANDLE)evt->seq);
+ if (it != m_mpOutMessages.end())
+ {
+ evt->dbei->timestamp = it->second;
+ m_mpOutMessages.erase(it);
+ }
+
+ return 0;
+}
|