Send unavailable presence to all muc when the IRC server closes the connection

This commit is contained in:
Florent Le Coz
2014-02-19 23:59:43 +01:00
parent aeae88dd32
commit 16be9af3fc
3 changed files with 7 additions and 2 deletions
+2
View File
@@ -46,6 +46,8 @@ void IrcClient::on_connection_close()
{ {
static const std::string message = "Connection closed by remote server."; static const std::string message = "Connection closed by remote server.";
this->send_gateway_message(message); this->send_gateway_message(message);
const IrcMessage error{"ERROR", {message}};
this->on_error(error);
log_warning(message); log_warning(message);
} }
+4 -2
View File
@@ -155,13 +155,15 @@ int Poller::poll(const std::chrono::milliseconds& timeout)
else if (this->fds[i].revents & POLLIN) else if (this->fds[i].revents & POLLIN)
{ {
auto socket_handler = this->socket_handlers.at(this->fds[i].fd); auto socket_handler = this->socket_handlers.at(this->fds[i].fd);
socket_handler->on_recv(); if (socket_handler->is_connected())
socket_handler->on_recv();
nb_events--; nb_events--;
} }
else if (this->fds[i].revents & POLLOUT) else if (this->fds[i].revents & POLLOUT)
{ {
auto socket_handler = this->socket_handlers.at(this->fds[i].fd); auto socket_handler = this->socket_handlers.at(this->fds[i].fd);
socket_handler->on_send(); if (socket_handler->is_connected())
socket_handler->on_send();
nb_events--; nb_events--;
} }
} }
+1
View File
@@ -100,6 +100,7 @@ void SocketHandler::on_send()
if (res == -1) if (res == -1)
{ {
log_error("send failed: " << strerror(errno)); log_error("send failed: " << strerror(errno));
this->on_connection_close();
this->close(); this->close();
} }
else else