summaryrefslogtreecommitdiffstats
path: root/src/ClientHandle.cpp
diff options
context:
space:
mode:
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();