summaryrefslogtreecommitdiffstats
path: root/src/ClientHandle.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-01-26 14:49:51 +0100
committerMattes D <github@xoft.cz>2015-01-27 14:53:38 +0100
commit19d463ae1c0faaf08a0783a01db81eae0a271b62 (patch)
treee601cdfb70dad08ef469cb00accc52aa4ff0ad40 /src/ClientHandle.cpp
parentAdded network termination called at app exit. (diff)
downloadcuberite-19d463ae1c0faaf08a0783a01db81eae0a271b62.tar
cuberite-19d463ae1c0faaf08a0783a01db81eae0a271b62.tar.gz
cuberite-19d463ae1c0faaf08a0783a01db81eae0a271b62.tar.bz2
cuberite-19d463ae1c0faaf08a0783a01db81eae0a271b62.tar.lz
cuberite-19d463ae1c0faaf08a0783a01db81eae0a271b62.tar.xz
cuberite-19d463ae1c0faaf08a0783a01db81eae0a271b62.tar.zst
cuberite-19d463ae1c0faaf08a0783a01db81eae0a271b62.zip
Diffstat (limited to 'src/ClientHandle.cpp')
-rw-r--r--src/ClientHandle.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 10920496d..c774a92c2 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -1824,10 +1824,7 @@ void cClientHandle::SendData(const char * a_Data, size_t a_Size)
}
cCSLock Lock(m_CSOutgoingData);
- if (m_Link != nullptr)
- {
- m_Link->Send(a_Data, a_Size);
- }
+ m_OutgoingData.append(a_Data, a_Size);
}
@@ -1888,6 +1885,17 @@ void cClientHandle::Tick(float a_Dt)
{
m_Protocol->DataReceived(IncomingData.data(), IncomingData.size());
}
+
+ // Send any queued outgoing data:
+ AString OutgoingData;
+ {
+ cCSLock Lock(m_CSOutgoingData);
+ std::swap(OutgoingData, m_OutgoingData);
+ }
+ if ((m_Link != nullptr) && !OutgoingData.empty())
+ {
+ m_Link->Send(OutgoingData.data(), OutgoingData.size());
+ }
m_TicksSinceLastPacket += 1;
if (m_TicksSinceLastPacket > 600) // 30 seconds time-out
@@ -1976,6 +1984,17 @@ void cClientHandle::ServerTick(float a_Dt)
m_Protocol->DataReceived(IncomingData.data(), IncomingData.size());
}
+ // Send any queued outgoing data:
+ AString OutgoingData;
+ {
+ cCSLock Lock(m_CSOutgoingData);
+ std::swap(OutgoingData, m_OutgoingData);
+ }
+ if ((m_Link != nullptr) && !OutgoingData.empty())
+ {
+ m_Link->Send(OutgoingData.data(), OutgoingData.size());
+ }
+
if (m_State == csAuthenticated)
{
StreamNextChunk();