[Session] Disable sessions for now to make the game more stable

This commit is contained in:
momo5502 2017-07-02 19:05:58 +02:00
parent 622242f3b0
commit 87b02f1b49
2 changed files with 12 additions and 0 deletions

View File

@ -17,6 +17,9 @@ namespace Components
void Session::Send(Network::Address target, std::string command, std::string data)
{
#ifdef DISABLE_SESSION
Network::SendCommand(target, command, data);
#else
std::lock_guard<std::recursive_mutex> _(Session::Mutex);
auto queue = Session::PacketQueue.find(target);
@ -33,12 +36,17 @@ namespace Components
packet->tries = 0;
queue->second.push(packet);
#endif
}
void Session::Handle(std::string packet, Utils::Slot<Network::Callback> callback)
{
#ifdef DISABLE_SESSION
Network::Handle(packet, callback);
#else
std::lock_guard<std::recursive_mutex> _(Session::Mutex);
Session::PacketHandlers[packet] = callback;
#endif
}
void Session::RunFrame()
@ -104,6 +112,7 @@ namespace Components
Session::Session()
{
#ifndef DISABLE_SESSION
Session::SignatureKey = Utils::Cryptography::ECC::GenerateKey(512);
//Scheduler::OnFrame(Session::RunFrame);
@ -161,6 +170,7 @@ namespace Components
handler->second(address, dataPacket.data());
});
#endif
}
Session::~Session()

View File

@ -4,6 +4,8 @@
#define SESSION_MAX_RETRIES 3
#define SESSION_REQUEST_LIMIT 3
#define DISABLE_SESSION
namespace Components
{
class Session : public Component