1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Do not accept connections into ongoing game

This commit is contained in:
Ivan Savenko
2023-12-26 16:29:06 +02:00
parent 5694777a96
commit c9765a52ff
3 changed files with 13 additions and 7 deletions

View File

@@ -178,22 +178,22 @@ void CVCMIServer::onNewConnection(const std::shared_ptr<NetworkConnection> & con
if(state == EServerState::LOBBY)
{
activeConnections.push_back(std::make_shared<CConnection>(connection));//, SERVER_NAME, uuid);)
activeConnections.push_back(std::make_shared<CConnection>(connection));
activeConnections.back()->enterLobbyConnectionMode();
}
// TODO: else: deny connection
// TODO: else: try to reconnect / send state to reconnected client
else
{
networkServer->closeConnection(connection);
}
}
void CVCMIServer::onPacketReceived(const std::shared_ptr<NetworkConnection> & connection, const std::vector<uint8_t> & message)
{
std::shared_ptr<CConnection> c = findConnection(connection);
CPack * pack = c->retrievePack(message);
auto pack = c->retrievePack(message);
pack->c = c;
CVCMIServerPackVisitor visitor(*this, this->gh);
pack->visit(visitor);
//FIXME: delete pack?
}
void CVCMIServer::onConnectionFailed(const std::string & errorMessage)