Skip to content

Commit

Permalink
Fix server-test
Browse files Browse the repository at this point in the history
  • Loading branch information
nerudaj committed Jun 19, 2024
1 parent a135d2c commit aef5d43
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/lib-network/src/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ void Server::update(std::function<void(const std::string&)> log)
sf::Packet packet;
for (auto&& [key, client] : registeredClients)
{
// FIXME: what if registeredClient is removed in the middle of the loop?
// --> deferred removal (or indexed removal)
if (client.socket->receive(packet) != sf::Socket::Status::Done)
continue;

Expand Down
3 changes: 2 additions & 1 deletion src/server-test/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ void serverLoop(Server server)
{
while (serverEnabled)
{
server.update();
server.update([](const std::string& log)
{ std::cout << log << std::endl; });
}
}

Expand Down

0 comments on commit aef5d43

Please sign in to comment.