[Node] Regularly store nodes

This commit is contained in:
momo5502 2017-06-26 00:01:58 +02:00
parent 6eb749cf93
commit 72fe016543
2 changed files with 6 additions and 7 deletions

View File

@ -169,6 +169,8 @@ namespace Components
++i;
}
Node::StoreNodes(false);
}
void Node::Synchronize()
@ -250,11 +252,6 @@ namespace Components
Session::Send(address, "nodeListResponse", list.SerializeAsString());
}
void Node::HandleRequest(Network::Address address, std::string /*data*/)
{
Node::SendList(address);
}
unsigned short Node::GetPort()
{
if (Dvar::Var("net_natFix").get<bool>()) return 0;
@ -268,7 +265,10 @@ namespace Components
Scheduler::OnFrame(Node::RunFrame);
Session::Handle("nodeListResponse", Node::HandleResponse);
Session::Handle("nodeListRequest", Node::HandleRequest);
Session::Handle("nodeListRequest", [](Network::Address address, std::string)
{
Node::SendList(address);
});
// Load stored nodes
auto loadNodes = []()

View File

@ -47,7 +47,6 @@ namespace Components
static std::vector<Entry> Nodes;
static void HandleResponse(Network::Address address, std::string data);
static void HandleRequest(Network::Address address, std::string data);
static void SendList(Network::Address address);