diff --git a/engine/shared/library/sharedNetwork/src/shared/Connection.cpp b/engine/shared/library/sharedNetwork/src/shared/Connection.cpp index aec8be2f..04770848 100755 --- a/engine/shared/library/sharedNetwork/src/shared/Connection.cpp +++ b/engine/shared/library/sharedNetwork/src/shared/Connection.cpp @@ -579,28 +579,22 @@ void Connection::onConnectionOverflowing(unsigned int totalBytes) void Connection::onConnectionClosed(Connection *) { - bool triggerOnConnectionClosed = true; // default - trigger the callback + if (getService()) + { + getService()->onConnectionClosed(this); + } + if (udpConnection) { - UdpConnection::DisconnectReason reason = udpConnection->GetDisconnectReason(); - - if (reason == UdpConnection::cDisconnectDosAsshole) { - triggerOnConnectionClosed = false; // no need - hopefully the destructor is just called - } - + UdpConnection::DisconnectReason reason = udpConnection->GetDisconnectReason(); setDisconnectReason("Connection::onConnectionClosed (udplibrary:%s)", UdpConnection::DisconnectReasonText(reason)); FATAL(ConfigSharedNetwork::getFatalOnConnectionClosed(), ("Connection closed %s", UdpConnection::DisconnectReasonText(reason))); } else - { - setDisconnectReason("Connection::onConnectionClosed called"); - } - - if (triggerOnConnectionClosed && getService()) - { - getService()->onConnectionClosed(this); - } + { + setDisconnectReason("Connection::onConnectionClosed called"); + } if (ConfigSharedNetwork::getLogConnectionOpenedClosed()) { diff --git a/engine/shared/library/sharedNetwork/src/shared/Service.cpp b/engine/shared/library/sharedNetwork/src/shared/Service.cpp index c3967278..49f6cb12 100755 --- a/engine/shared/library/sharedNetwork/src/shared/Service.cpp +++ b/engine/shared/library/sharedNetwork/src/shared/Service.cpp @@ -192,7 +192,7 @@ Service::~Service() } //----------------------------------------------------------------------- - + void Service::onConnectionClosed(Connection * c) { if (c) @@ -201,7 +201,9 @@ void Service::onConnectionClosed(Connection * c) if (f != connections.end()) { if (m_tcpServer) + { m_tcpServer->onConnectionClosed(c->getTcpClient()); + } connections.erase(f); } c->setService(0); @@ -214,16 +216,16 @@ void Service::onConnectionOpened(Connection * c) { if (c) { - if (connections.size() < static_cast(m_maxConnections)) - { - c->setService(this); - c->onConnectionOpened(); - connections.insert(c); + if (connections.size() < static_cast(m_maxConnections)) + { + c->setService(this); + c->onConnectionOpened(); + connections.insert(c); } - else - { - WARNING(true, ("Service has reached it's maximum connection count (%d).", m_maxConnections)); - } + else + { + WARNING(true, ("Service has reached it's maximum connection count (%d).", m_maxConnections)); + } } }