diff options
author | George Hazan <ghazan@miranda.im> | 2020-02-20 21:23:22 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-02-20 21:23:22 +0300 |
commit | dd6ac172c4f814fa4b5ace6caca80d00d7e01ac8 (patch) | |
tree | 805abd69e64f8e1f268e6415689de8742cac2215 /protocols/Twitter/src/proto.cpp | |
parent | 79d99837e0fefa32d695dba7e2a13b8a42f39da2 (diff) |
bunch of useless threads replaced with a call of ProtoBroadcastAsync
Diffstat (limited to 'protocols/Twitter/src/proto.cpp')
-rw-r--r-- | protocols/Twitter/src/proto.cpp | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp index 3629a59f35..e2780da7b1 100644 --- a/protocols/Twitter/src/proto.cpp +++ b/protocols/Twitter/src/proto.cpp @@ -118,33 +118,6 @@ INT_PTR CTwitterProto::GetCaps(int type, MCONTACT) /////////////////////////////////////////////////////////////////////////////////////////
-struct TSendDirect
-{
- __inline TSendDirect(MCONTACT _hContact, const CMStringA &_msg, int _msgid) :
- hContact(_hContact), msg(_msg), msgid(_msgid)
- {}
-
- MCONTACT hContact;
- CMStringA msg;
- int msgid;
-};
-
-void CTwitterProto::SendSuccess(void *p)
-{
- if (p == nullptr)
- return;
-
- auto *data = (TSendDirect*)p;
-
- CMStringA id(getMStringA(data->hContact, TWITTER_KEY_ID));
- if (!id.IsEmpty()) {
- send_direct(id, data->msg);
- ProtoBroadcastAck(data->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)data->msgid, 0);
- }
-
- delete data;
-}
-
MEVENT CTwitterProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT *pre)
{
MEVENT res = CSuper::RecvMsg(hContact, pre);
@@ -158,8 +131,14 @@ int CTwitterProto::SendMsg(MCONTACT hContact, int, const char *msg) if (m_iStatus != ID_STATUS_ONLINE)
return 0;
+ CMStringA id(getMStringA(hContact, TWITTER_KEY_ID));
+ if (id.IsEmpty())
+ return 0;
+
+ send_direct(id, msg);
+
int seq = InterlockedIncrement(&g_msgid);
- ForkThread(&CTwitterProto::SendSuccess, new TSendDirect(hContact, msg, seq));
+ ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)seq);
return seq;
}
|