diff --git a/src/app/Common.cpp b/src/app/Common.cpp index 099460f..cb4fea1 100644 --- a/src/app/Common.cpp +++ b/src/app/Common.cpp @@ -292,7 +292,7 @@ namespace Apostol { } } if (uid.Name.Length() >= 35 && uid.Name.SubString(0, 3) == BM_PREFIX) { #ifdef _DEBUG - ServerList.AddPair(BPS_BM_DEBUG_ADDRESS, BPS_DEBUG_SERVER_URL); + ServerList.AddPair(BPS_DEBUG_SERVER_URL, BPS_DEBUG_SERVER_URL); #endif CStringList urlList; if (FindURLInLine(uid.Desc, urlList)) { @@ -345,7 +345,7 @@ namespace Apostol { auto OnDone = [this, &Context, &Provider](CTCPConnection *Sender) { - auto pConnection = dynamic_cast (Sender); + const auto pConnection = dynamic_cast (Sender); const auto &Reply = pConnection->Reply(); DebugReply(Reply); @@ -407,7 +407,7 @@ namespace Apostol { auto OnDone = [this, &Context, &Provider](CTCPConnection *Sender) { - auto pConnection = dynamic_cast (Sender); + const auto pConnection = dynamic_cast (Sender); const auto &Reply = pConnection->Reply(); DebugReply(Reply); @@ -804,7 +804,7 @@ namespace Apostol { Context.SetStatus(Context::csInitialization); - auto pConnection = dynamic_cast (AConnection); + const auto pConnection = dynamic_cast (AConnection); if (pConnection != nullptr) { auto &Reply = pConnection->Reply(); diff --git a/src/app/Common.hpp b/src/app/Common.hpp index 3de7ee9..9d392da 100644 --- a/src/app/Common.hpp +++ b/src/app/Common.hpp @@ -60,7 +60,6 @@ namespace Apostol { void UpdateServerList(TPairs &ClassList, const CString &Key) { CStringPairs ServerList; CStringList Keys; - int index; ParsePGPKey(Key, ServerList, Keys); @@ -68,11 +67,8 @@ namespace Apostol { CStringPairs::ConstEnumerator em(ServerList); while (em.MoveNext()) { const auto &caCurrent = em.Current(); -#ifndef _DEBUG - if (caCurrent.Name() == BPS_BM_DEBUG_ADDRESS) - continue; -#endif - index = ClassList.IndexOfName(caCurrent.Name()); + int index = ClassList.IndexOfName(caCurrent.Name()); + if (index == -1) { index = ClassList.AddPair(caCurrent.Name(), ClassName(caCurrent.Name(), CLocation(caCurrent.Value()))); auto &Context = ClassList[index].Value(); diff --git a/src/modules/Workers/WebService/WebService.cpp b/src/modules/Workers/WebService/WebService.cpp index 22c6ae3..10fb7ee 100644 --- a/src/modules/Workers/WebService/WebService.cpp +++ b/src/modules/Workers/WebService/WebService.cpp @@ -69,13 +69,12 @@ namespace Apostol { if (m_Servers.Count() == 0) { #ifdef _DEBUG - const int index = m_Servers.AddPair(BPS_BM_DEBUG_ADDRESS, CContext(BPS_BM_DEBUG_ADDRESS, CLocation(BPS_DEBUG_SERVER_URL))); + const int index = m_Servers.AddPair(BPS_DEBUG_SERVER_URL, CContext(BPS_BM_DEBUG_ADDRESS, CLocation(BPS_DEBUG_SERVER_URL))); auto &Keys = m_Servers[index].Value().PGP(); Keys.Add(CKeyContext(CString("PUBLIC"), CString())); Keys.Add(CKeyContext(CString(BPS_BM_DEBUG_ADDRESS), CString())); -#else - m_Servers.Add(m_DefaultServer); #endif + m_Servers.Add(m_DefaultServer); } } //-------------------------------------------------------------------------------------------------------------- @@ -1111,10 +1110,10 @@ namespace Apostol { auto OnExecute = [this, &Context](CTCPConnection *AConnection) { - auto pConnection = dynamic_cast (AConnection); + const auto pConnection = dynamic_cast (AConnection); if (pConnection != nullptr) { - auto pClient = dynamic_cast (pConnection->Client()); + const auto pClient = dynamic_cast (pConnection->Client()); const auto &Reply = pConnection->Reply(); DebugReply(Reply); @@ -1163,9 +1162,9 @@ namespace Apostol { }; auto OnException = [&Context](CTCPConnection *AConnection, const Delphi::Exception::Exception &E) { - auto pConnection = dynamic_cast (AConnection); + const auto pConnection = dynamic_cast (AConnection); if (pConnection != nullptr) { - auto pClient = dynamic_cast (pConnection->Client()); + const auto pClient = dynamic_cast (pConnection->Client()); if (pClient != nullptr) { const auto &name = pClient->Data()["name"]; auto &Keys = Context.PGP(); @@ -1198,7 +1197,7 @@ namespace Apostol { Key.StatusTime = Now(); Key.RunTime = Key.StatusTime; - auto pClient = GetClient(Context.URL().hostname, Context.URL().port == 0 ? BPS_SERVER_PORT : Context.URL().port); + const auto pClient = GetClient(Context.URL().hostname, Context.URL().port == 0 ? BPS_SERVER_PORT : Context.URL().port); pClient->Data().AddPair("name", Key.Name); @@ -1249,10 +1248,7 @@ namespace Apostol { void CWebService::Heartbeat(CDateTime Now) { for (int i = 0; i < m_Servers.Count(); i++) { auto &Context = m_Servers[i].Value(); -#ifndef _DEBUG - if (Context.Name() == BPS_BM_DEBUG_ADDRESS) - continue; -#endif + if (Now >= Context.CheckDate()) { Context.SetCheckDate(Now + (CDateTime) 30 / SecsPerDay); // 30 sec diff --git a/src/modules/Workers/WebSocket/WebSocket.cpp b/src/modules/Workers/WebSocket/WebSocket.cpp index 1ccad83..1ec9464 100644 --- a/src/modules/Workers/WebSocket/WebSocket.cpp +++ b/src/modules/Workers/WebSocket/WebSocket.cpp @@ -68,7 +68,7 @@ namespace Apostol { if (m_Servers.Count() == 0) { #ifdef _DEBUG - const int index = m_Servers.AddPair(BPS_BM_DEBUG_ADDRESS, CClientContext(BPS_BM_DEBUG_ADDRESS, CLocation(BPS_DEBUG_SERVER_URL))); + const int index = m_Servers.AddPair(BPS_DEBUG_SERVER_URL, CClientContext(BPS_BM_DEBUG_ADDRESS, CLocation(BPS_DEBUG_SERVER_URL))); auto &Keys = m_Servers[index].Value().PGP(); Keys.Add(CKeyContext(CString("PUBLIC"), CString())); Keys.Add(CKeyContext(CString(BPS_BM_DEBUG_ADDRESS), CString())); @@ -139,7 +139,7 @@ namespace Apostol { CWebSocketClient *CWebSocketModule::GetConnectedClient(const CClientContext &Context) { for (int i = 0; i < Context.ClientManager().Count(); i++) { - auto pClient = Context.ClientManager()[i]; + const auto pClient = Context.ClientManager()[i]; if (pClient->Connected()) return pClient; } @@ -154,8 +154,8 @@ namespace Apostol { while (index < m_Servers.Count()) { const auto &caContext = m_Servers[index].Value(); if (caContext.Status() == Context::csRunning) { - if (Params.IsEmpty() || Params == caContext.URL().Origin()) { - auto pClient = GetConnectedClient(caContext); + if (Params.IsEmpty() || Params == caContext.Name() || Params == caContext.URL().Origin()) { + const auto pClient = GetConnectedClient(caContext); if (pClient != nullptr) return index; } @@ -1111,10 +1111,7 @@ namespace Apostol { void CWebSocketModule::Heartbeat(CDateTime Now) { for (int i = 0; i < m_Servers.Count(); i++) { auto &Context = m_Servers[i].Value(); -#ifndef _DEBUG - if (Context.Name() == BPS_BM_DEBUG_ADDRESS) - continue; -#endif + if (Now >= Context.CheckDate()) { Context.SetCheckDate(Now + (CDateTime) 30 / SecsPerDay); // 30 sec @@ -1136,7 +1133,7 @@ namespace Apostol { if (Context.Status() == Context::csRunning) { for (int j = 0; j < Context.ClientManager().Count(); ++j) { - auto pClient = Context.ClientManager()[j]; + const auto pClient = Context.ClientManager()[j]; if (!pClient->Active()) pClient->Active(true);