Revalidate invalid servers.
This commit is contained in:
parent
8f91c7dc6a
commit
a49e668615
@ -182,6 +182,30 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Node::PerformRegistration(Network::Address address)
|
||||||
|
{
|
||||||
|
Node::NodeEntry* entry = Node::FindNode(address);
|
||||||
|
if (!entry) return;
|
||||||
|
|
||||||
|
entry->lastTime = Game::Com_Milliseconds();
|
||||||
|
|
||||||
|
if (Dedicated::IsDedicated())
|
||||||
|
{
|
||||||
|
entry->challenge = Utils::VA("%X", Utils::Cryptography::Rand::GenerateInt());
|
||||||
|
|
||||||
|
Proto::Node::Packet packet;
|
||||||
|
packet.set_challenge(entry->challenge);
|
||||||
|
|
||||||
|
Logger::Print("Sending registration request to %s\n", entry->address.GetString());
|
||||||
|
Network::SendCommand(entry->address, "nodeRegisterRequest", packet.SerializeAsString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger::Print("Sending session request to %s\n", entry->address.GetString());
|
||||||
|
Network::SendCommand(entry->address, "sessionRequest");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Node::FrameHandler()
|
void Node::FrameHandler()
|
||||||
{
|
{
|
||||||
int registerCount = 0;
|
int registerCount = 0;
|
||||||
@ -207,23 +231,15 @@ namespace Components
|
|||||||
{
|
{
|
||||||
registerCount++;
|
registerCount++;
|
||||||
node.state = Node::STATE_NEGOTIATING;
|
node.state = Node::STATE_NEGOTIATING;
|
||||||
node.lastTime = Game::Com_Milliseconds();
|
Node::PerformRegistration(node.address);
|
||||||
|
}
|
||||||
if (Dedicated::IsDedicated())
|
// Requery invalid nodes within the NODE_QUERY_INTERVAL
|
||||||
{
|
// This is required, as a node might crash, which causes it to be invalid
|
||||||
node.challenge = Utils::VA("%X", Utils::Cryptography::Rand::GenerateInt());
|
// If it's restarted though, we wouldn't query it again
|
||||||
|
else if (node.state == STATE_INVALID && (Game::Com_Milliseconds() - node.lastTime) >(NODE_QUERY_INTERVAL))
|
||||||
Proto::Node::Packet packet;
|
{
|
||||||
packet.set_challenge(node.challenge);
|
registerCount++;
|
||||||
|
Node::PerformRegistration(node.address);
|
||||||
Logger::Print("Sending registration request to %s\n", node.address.GetString());
|
|
||||||
Network::SendCommand(node.address, "nodeRegisterRequest", packet.SerializeAsString());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Logger::Print("Sending session request to %s\n", node.address.GetString());
|
|
||||||
Network::SendCommand(node.address, "sessionRequest");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +62,7 @@ namespace Components
|
|||||||
static void LoadNodes();
|
static void LoadNodes();
|
||||||
static void StoreNodes(bool force);
|
static void StoreNodes(bool force);
|
||||||
|
|
||||||
|
static void PerformRegistration(Network::Address address);
|
||||||
static void SendNodeList(Network::Address address);
|
static void SendNodeList(Network::Address address);
|
||||||
static NodeEntry* FindNode(Network::Address address);
|
static NodeEntry* FindNode(Network::Address address);
|
||||||
static ClientSession* FindSession(Network::Address address);
|
static ClientSession* FindSession(Network::Address address);
|
||||||
|
Loading…
Reference in New Issue
Block a user