From 1f49e7e4350298dad2e0a6e340b608a80a625e4b Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Thu, 30 Jul 2020 04:38:19 +0500 Subject: Network usage optimization --- src/Stream.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/Stream.cpp') diff --git a/src/Stream.cpp b/src/Stream.cpp index efe37d2..5c99724 100644 --- a/src/Stream.cpp +++ b/src/Stream.cpp @@ -360,9 +360,14 @@ void StreamSocket::ReadData(unsigned char *buffPtr, size_t buffLen) { } void StreamSocket::WriteData(unsigned char *buffPtr, size_t buffLen) { - socket->Write(buffPtr, buffLen); + std::copy(buffPtr, buffPtr + buffLen, std::back_inserter(buffer)); } StreamSocket::StreamSocket(Socket *socketPtr) : socket(socketPtr) { -} \ No newline at end of file +} + +void StreamSocket::Flush() { + socket->Write(buffer.data(), buffer.size()); + buffer.clear(); +} -- cgit v1.2.3