From 58d904a328c0d849769b483e901a0be9426b8209 Mon Sep 17 00:00:00 2001 From: liuxiaolong <liuxiaolong@aiotlink.com> Date: 星期二, 20 七月 2021 20:20:44 +0800 Subject: [PATCH] 调整Request C.BHFree的位置 --- box/tcp_connection.cpp | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/box/tcp_connection.cpp b/box/tcp_connection.cpp index 85ed4ed..8f0fe86 100644 --- a/box/tcp_connection.cpp +++ b/box/tcp_connection.cpp @@ -63,7 +63,7 @@ if (4 > len) { return false; } uint32_t head_len = Get32(p); if (head_len > 1024 * 4) { - throw std::runtime_error("unexpected tcp reply data."); + throw std::runtime_error("unexpected tcp data head."); } auto before_body = 4 + head_len + 4; if (before_body > len) { @@ -178,8 +178,17 @@ send_buffer_ = imsg.content(); async_write(socket_, Buffer(send_buffer_), TcpCBSize(*this, [this]() { Close(); })); }; + auto &scenter = *pscenter_; - if (scenter->PassRemoteRequestToLocal(remote, head, body_content, onRecv)) { + if (head.type() == kMsgTypePublish) { + auto reply = MakeReply(eSuccess); + auto rep_head = InitMsgHead(GetType(reply), scenter->id(), 0, head.msg_id()); + send_buffer_ = MsgI::Serialize(rep_head, reply); + async_write(socket_, Buffer(send_buffer_), TcpCBSize(*this, [this]() { Close(); })); + + scenter->RemotePublish(head, body_content); + return; + } else if (scenter->PassRemoteRequestToLocal(remote, head, body_content, onRecv)) { return; } else { Close(); -- Gitblit v1.8.0