diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2021-03-28 15:44:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-28 15:44:20 +0200 |
commit | 2687f2df30210ada485c28c98e52db08d460d5a3 (patch) | |
tree | d0b25a9c996c1dd72e3ed4840dded5e8642d4342 /src/ClientHandle.cpp | |
parent | Do not fake a tool when converting to pickups (#5170) (diff) | |
download | cuberite-2687f2df30210ada485c28c98e52db08d460d5a3.tar cuberite-2687f2df30210ada485c28c98e52db08d460d5a3.tar.gz cuberite-2687f2df30210ada485c28c98e52db08d460d5a3.tar.bz2 cuberite-2687f2df30210ada485c28c98e52db08d460d5a3.tar.lz cuberite-2687f2df30210ada485c28c98e52db08d460d5a3.tar.xz cuberite-2687f2df30210ada485c28c98e52db08d460d5a3.tar.zst cuberite-2687f2df30210ada485c28c98e52db08d460d5a3.zip |
Diffstat (limited to 'src/ClientHandle.cpp')
-rw-r--r-- | src/ClientHandle.cpp | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 26db7c2df..20b03e190 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -231,6 +231,27 @@ bool cClientHandle::IsUUIDOnline(const cUUID & a_UUID) +void cClientHandle::ProcessProtocolOut() +{ + decltype(m_OutgoingData) OutgoingData; + { + cCSLock Lock(m_CSOutgoingData); + std::swap(OutgoingData, m_OutgoingData); + } + + // Due to cTCPLink's design of holding a strong pointer to ourself, we need to explicitly reset m_Link. + // This means we need to check it's not nullptr before trying to send, but also capture the link, + // to prevent it being reset between the null check and the Send: + if (auto Link = m_Link; Link != nullptr) + { + Link->Send(OutgoingData.data(), OutgoingData.size()); + } +} + + + + + void cClientHandle::Kick(const AString & a_Reason) { if (m_State >= csAuthenticating) // Don't log pings @@ -1899,14 +1920,8 @@ void cClientHandle::SendData(const ContiguousByteBufferView a_Data) return; } - // Due to cTCPLink's design of holding a strong pointer to ourself, we need to explicitly reset m_Link. - // This means we need to check it's not nullptr before trying to send, but also capture the link, - // to prevent it being reset between the null check and the Send: - if (auto Link = m_Link; Link != nullptr) - { - cCSLock Lock(m_CSOutgoingData); - Link->Send(a_Data.data(), a_Data.size()); - } + cCSLock Lock(m_CSOutgoingData); + m_OutgoingData += a_Data; } |