From 72fe016543a2ffbbb50930691bfcc095c1bc9fe6 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Mon, 26 Jun 2017 00:01:58 +0200 Subject: [PATCH] [Node] Regularly store nodes --- src/Components/Modules/Node.cpp | 12 ++++++------ src/Components/Modules/Node.hpp | 1 - 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Components/Modules/Node.cpp b/src/Components/Modules/Node.cpp index facae0e8..a35ff65f 100644 --- a/src/Components/Modules/Node.cpp +++ b/src/Components/Modules/Node.cpp @@ -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()) 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 = []() diff --git a/src/Components/Modules/Node.hpp b/src/Components/Modules/Node.hpp index 44502488..8fa82da1 100644 --- a/src/Components/Modules/Node.hpp +++ b/src/Components/Modules/Node.hpp @@ -47,7 +47,6 @@ namespace Components static std::vector 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);