mirror of
https://github.com/alterware/master-server.git
synced 2026-01-08 00:01:50 +00:00
init
This commit is contained in:
39
src/server_list.cpp
Normal file
39
src/server_list.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "std_include.hpp"
|
||||
#include "server_list.hpp"
|
||||
|
||||
void server_list::find_registered_servers(const game_type game, const int protocol, const access_func& accessor)
|
||||
{
|
||||
this->iterate([&](iteration_context& context)
|
||||
{
|
||||
auto& server = context.get();
|
||||
if (server.registered && server.game == game && server.protocol == protocol)
|
||||
{
|
||||
accessor(server, context.get_address());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void server_list::find_registered_servers(const game_type game, const int protocol,
|
||||
const const_access_func& accessor) const
|
||||
{
|
||||
this->iterate([&](const iteration_context& context)
|
||||
{
|
||||
const auto& server = context.get();
|
||||
if (server.registered && server.game == game && server.protocol == protocol)
|
||||
{
|
||||
accessor(server, context.get_address());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void server_list::heartbeat(const network::address& address)
|
||||
{
|
||||
this->insert(address, [](game_server& server)
|
||||
{
|
||||
if (server.state == game_server::state::can_ping)
|
||||
{
|
||||
server.heartbeat = std::chrono::high_resolution_clock::now();
|
||||
server.state = game_server::state::needs_ping;
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user