Send the reason of the connection close to the user

This commit is contained in:
Florent Le Coz
2014-07-15 15:39:25 +02:00
parent 4582f10797
commit 11a31db2d5
6 changed files with 21 additions and 17 deletions
+4 -2
View File
@@ -93,9 +93,11 @@ void IrcClient::on_connected()
this->send_pending_data();
}
void IrcClient::on_connection_close()
void IrcClient::on_connection_close(const std::string& error_msg)
{
static const std::string message = "Connection closed by remote server.";
std::string message = "Connection closed by remote server.";
if (!error_msg.empty())
message += ": " + error_msg;
const IrcMessage error{"ERROR", {message}};
this->on_error(error);
log_warning(message);
+1 -1
View File
@@ -41,7 +41,7 @@ public:
/**
* Close the connection, remove us from the poller
*/
void on_connection_close() override final;
void on_connection_close(const std::string& error) override final;
/**
* Parse the data we have received so far and try to get one or more
* complete messages from it.