diff options
author | Stijn Buys <ingar@osirion.org> | 2008-03-16 10:00:16 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-03-16 10:00:16 +0000 |
commit | 9a7ca1743f0c74042bca4d4903f7e56fe810edce (patch) | |
tree | a91faf4d038eb2c45e932c018ced0952414b730b /src/core/netclient.cc | |
parent | c186b58679c50b06966997d33d5e91a99c5621ea (diff) |
accumulate client sends in the gameserver, transmit bufffer at the end of the server frame
Diffstat (limited to 'src/core/netclient.cc')
-rw-r--r-- | src/core/netclient.cc | 20 |
1 files changed, 20 insertions, 0 deletions
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); + } + } +} + } |