Automatically finalize any delayed update objects
This commit is contained in:
parent
8defbe7569
commit
66d372d810
4 changed files with 38 additions and 7 deletions
|
|
@ -1,9 +1,17 @@
|
|||
#include "DelayUpdateSerializedClassManager.hpp"
|
||||
#include <chrono>
|
||||
|
||||
namespace NetworkingObjects {
|
||||
void DelayUpdateSerializedClassManager::update() {
|
||||
void DelayUpdateSerializedClassManager::update(NetworkingObjects::NetObjManager& netObjMan) {
|
||||
for(auto& [objID, updatingObj] : updatingObjs) {
|
||||
if(updatingObj.lastTemporaryUpdateTimePoint.has_value() && (std::chrono::steady_clock::now() - updatingObj.lastTemporaryUpdateTimePoint.value()) >= std::chrono::milliseconds(300)) {
|
||||
updatingObj.sendFinalUpdate();
|
||||
std::cout << "yay!" << std::endl;
|
||||
updatingObj.lastTemporaryUpdateTimePoint = std::nullopt;
|
||||
}
|
||||
}
|
||||
std::erase_if(updatingObjs, [](auto& updatingPair) {
|
||||
if((std::chrono::steady_clock::now() - updatingPair.second.lastUpdateTimePoint) >= std::chrono::seconds(3)) {
|
||||
if((std::chrono::steady_clock::now() - updatingPair.second.lastUpdateTimePoint) >= std::chrono::seconds(3) && !updatingPair.second.lastTemporaryUpdateTimePoint.has_value()) {
|
||||
updatingPair.second.setDataAfterTimeout();
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue