diff options
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); + } + } +} + } |