From 9490d406c176ed1d7b6a1803b1dce0ed24ba18f6 Mon Sep 17 00:00:00 2001 From: ljc545w Date: Fri, 30 Sep 2022 00:50:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86=E5=B7=B2?= =?UTF-8?q?=E7=9F=A5bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DWeChatRobot/ReceiveMessage.cpp | 12 ++++++++++-- Python/com/wxRobot.py | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/DWeChatRobot/ReceiveMessage.cpp b/DWeChatRobot/ReceiveMessage.cpp index 3f23143..3fa667f 100644 --- a/DWeChatRobot/ReceiveMessage.cpp +++ b/DWeChatRobot/ReceiveMessage.cpp @@ -139,10 +139,18 @@ void SendSocketMessageInThread(SocketMessageStruct *param) string jstr = jMsg.dump() + "\n"; LOG(INFO) << "msgid: " << jMsg["msgid"].get() << " send begin." << endl; LOG(INFO) << "type: " << jMsg["type"].get() << ", sender: " << jMsg["wxid"].get() << endl; - LOG(INFO) << "content: " << jMsg["message"].get() << endl; + LOG(INFO) << "content size: " << jstr.length() << endl; #ifdef USE_COM // 通过连接点,将消息广播给客户端;将广播过程放在线程中完成,客户端才可以等待图片、语音落地 - VARIANT vsaValue = (_variant_t)utf8_to_unicode(jstr.c_str()).c_str(); + VARIANT vsaValue; + _variant_t szWMsg = (_variant_t)utf8_to_unicode(jstr.c_str()).c_str(); + vsaValue.vt = VT_ARRAY | VT_VARIANT; + SAFEARRAYBOUND rgsaBound = {1, 0}; + SAFEARRAY *psaValue = SafeArrayCreate(VT_VARIANT, 1, &rgsaBound); + long index = 0; + // 数据大小超过16382个字符,客户端调用可能出现异常,因此将数据放入安全数组中传递 + HRESULT hr = SafeArrayPutElement(psaValue, &index, &szWMsg); + V_ARRAY(&vsaValue) = psaValue; DWORD type = jMsg["type"].get(); ULONG64 msgid = (type != 10000) ? jMsg["msgid"].get() : 0; PostComMessage(jMsg["pid"].get(), WX_MESSAGE, msgid, &vsaValue); diff --git a/Python/com/wxRobot.py b/Python/com/wxRobot.py index 0e2da46..b10c246 100644 --- a/Python/com/wxRobot.py +++ b/Python/com/wxRobot.py @@ -51,7 +51,7 @@ class WeChatEventSink: """ def OnGetMessageEvent(self, msg): - msg = json.loads(msg) + msg = json.loads(msg[0]) print(msg) -- GitLab