From 9a7ca1743f0c74042bca4d4903f7e56fe810edce Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 16 Mar 2008 10:00:16 +0000 Subject: accumulate client sends in the gameserver, transmit bufffer at the end of the server frame --- src/core/netclient.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/core/netclient.cc') diff --git a/src/core/netclient.cc b/src/core/netclient.cc index 7b5d554..937cf21 100644 --- a/src/core/netclient.cc +++ b/src/core/netclient.cc @@ -26,6 +26,9 @@ NetClient::NetClient(int clientfd, std::string host, int port) : client_host = host; client_port = port; + + sendq.clear(); + messageblock.clear(); } NetClient::~NetClient() @@ -87,4 +90,21 @@ void NetClient::receive() datablock.clear(); } +void NetClient::send(std::string const &msg) +{ + sendq.append(msg); +} + +void NetClient::transmit() +{ + while (sendq.size() && !error()) { + TCPClient::send(sendq.substr(0, net::FRAMESIZE-1)); + if (sendq.size() < net::FRAMESIZE) { + sendq.clear(); + } else { + sendq.erase(0, net::FRAMESIZE-1); + } + } +} + } -- cgit v1.2.3