From af9701a816b1cce10706a8f1a67d5a18120a1e0f Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Thu, 29 Sep 2016 03:48:11 +0000 Subject: [PATCH] clion, your formatting is pissing me off --- .../sharedNetwork/src/shared/Connection.cpp | 24 +++++++------------ .../sharedNetwork/src/shared/Service.cpp | 22 +++++++++-------- 2 files changed, 21 insertions(+), 25 deletions(-) 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)); + } } }