[Session] Resend packets

This commit is contained in:
momo5502 2017-07-10 18:31:48 +02:00
parent d153c98408
commit 9fcd31616e

View File

@ -18,7 +18,26 @@ namespace Components
void Session::Send(Network::Address target, std::string command, std::string data) void Session::Send(Network::Address target, std::string command, std::string data)
{ {
#ifdef DISABLE_SESSION #ifdef DISABLE_SESSION
class DelayedResend
{
public:
Network::Address target;
std::string command;
std::string data;
};
DelayedResend* delayData = new DelayedResend;
delayData->target = target;
delayData->command = command;
delayData->data = data;
Network::SendCommand(target, command, data); Network::SendCommand(target, command, data);
Scheduler::OnDelay([delayData]()
{
Network::SendCommand(delayData->target, delayData->command, delayData->data);
delete delayData;
}, 500ms + std::chrono::milliseconds(rand() % 200));
#else #else
std::lock_guard<std::recursive_mutex> _(Session::Mutex); std::lock_guard<std::recursive_mutex> _(Session::Mutex);