mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
Fix connection termination handling
This commit is contained in:
parent
2bb96018b8
commit
93038b791e
@ -913,7 +913,6 @@ void CServerHandler::onDisconnected(const std::shared_ptr<INetworkConnection> &
|
||||
|
||||
if(getState() == EClientState::DISCONNECTING)
|
||||
{
|
||||
assert(networkConnection == nullptr);
|
||||
// Note: this branch can be reached on app shutdown, when main thread holds mutex till destruction
|
||||
logNetwork->info("Successfully closed connection to server!");
|
||||
return;
|
||||
|
@ -49,9 +49,11 @@ void NetworkServer::connectionAccepted(std::shared_ptr<NetworkSocket> upcomingCo
|
||||
void NetworkServer::onDisconnected(const std::shared_ptr<INetworkConnection> & connection, const std::string & errorMessage)
|
||||
{
|
||||
logNetwork->info("Connection lost! Reason: %s", errorMessage);
|
||||
assert(connections.count(connection));
|
||||
if (connections.count(connection))
|
||||
{
|
||||
connections.erase(connection);
|
||||
listener.onDisconnected(connection, errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkServer::onPacketReceived(const std::shared_ptr<INetworkConnection> & connection, const std::vector<std::byte> & message)
|
||||
|
@ -51,6 +51,8 @@ void GlobalLobbyProcessor::onDisconnected(const std::shared_ptr<INetworkConnecti
|
||||
message["accountID"].String() = proxy.first;
|
||||
|
||||
sendMessage(controlConnection, message);
|
||||
|
||||
proxyConnections.erase(proxy.first);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user