Moved UDP logic from Hybrid server/client to UDP server/client. fixed bug in Server::CheckForTimeOuts.

This commit is contained in:
Jocke
2016-02-08 14:32:00 +01:00
parent 88d7b79cd3
commit ba9419b342
16 changed files with 271 additions and 230 deletions
+5 -2
View File
@@ -9,7 +9,6 @@ Server::Server()
}
Server::~Server()
{
}
void Server::Start(World* world, EventBroker* eventBroker)
{
@@ -154,16 +153,20 @@ void Server::checkForTimeOuts()
int startPing = 1000 * m_StartPingTime
/ static_cast<double>(CLOCKS_PER_SEC);
std::vector<PlayerID> playersToRemove;
for (auto& kv : m_ConnectedPlayers) {
if (kv.second.Address != boost::asio::ip::address()) {
int stopPing = 1000 * kv.second.StopTime /
static_cast<double>(CLOCKS_PER_SEC);
if (startPing > stopPing + m_TimeoutMs) {
LOG_INFO("User %i timed out!", kv.second.Name);
disconnect(kv.first);
playersToRemove.push_back(kv.first);
}
}
}
for (size_t i = 0; i < playersToRemove.size(); i++) {
disconnect(playersToRemove.at(i));
}
}
void Server::parseDisconnect()