Skip to content
This repository has been archived by the owner on Apr 6, 2019. It is now read-only.

Commit

Permalink
change behavior of on_new_connection_handler. Returning true means co…
Browse files Browse the repository at this point in the history
…nnection is handled by tcp_client wrapper and nothing will be done by tcp_server. Returning false means connection is handled by tcp_server, will be stored in an internal list and tcp_client disconection_handler overriden.
  • Loading branch information
Simon Ninon committed Jun 11, 2017
1 parent a6b6010 commit b1ba179
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sources/network/tcp_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ tcp_server::on_read_available(fd_t) {

auto client = std::make_shared<tcp_client>(m_socket.accept());

if (!m_on_new_connection_callback || m_on_new_connection_callback(client)) {
__TACOPIE_LOG(info, "tcp_server accepted new connection");
if (!m_on_new_connection_callback || !m_on_new_connection_callback(client)) {
__TACOPIE_LOG(info, "connection handling delegated to tcp_server");

client->set_on_disconnection_handler(std::bind(&tcp_server::on_client_disconnected, this, client));
m_clients.push_back(client);
}
else {
__TACOPIE_LOG(info, "tcp_server dismissed new connection");
__TACOPIE_LOG(info, "connection handled by tcp_server wrapper");
}
}
catch (const tacopie::tacopie_error&) {
Expand Down Expand Up @@ -170,4 +170,4 @@ tcp_server::operator!=(const tcp_server& rhs) const {
return !operator==(rhs);
}

} //! tacopie
} // namespace tacopie

0 comments on commit b1ba179

Please sign in to comment.