Do not send data if we are connected, send it only once we actually are
This commit is contained in:
1 parent
3b1bf740a3
commit
e196d2f1f4
4 files changed
+17
-1
No files matched your search
@@ -238,7 +238,14 @@ void SocketHandler::send_data(std::string&& data)
|
||||
if (data.empty())
|
||||
return ;
|
||||
this->out_buf.emplace_back(std::move(data));
|
||||
this->poller->watch_send_events(this);
|
||||
if (this->connected)
|
||||
this->poller->watch_send_events(this);
|
||||
}
|
||||
|
||||
void SocketHandler::send_pending_data()
|
||||
{
|
||||
if (this->connected && !this->out_buf.empty())
|
||||
this->poller->watch_send_events(this);
|
||||
}
|
||||
|
||||
bool SocketHandler::is_connected() const
|
||||
|
||||
@@ -51,6 +51,10 @@ public:
|
||||
* notified when a send event is ready.
|
||||
*/
|
||||
void send_data(std::string&& data);
|
||||
/**
|
||||
* Watch the socket for send events, if our out buffer is not empty.
|
||||
*/
|
||||
void send_pending_data();
|
||||
/**
|
||||
* Returns the socket that should be handled by the poller.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user