Fixed bug.
This commit is contained in:
@@ -292,7 +292,7 @@ namespace Apostol {
|
|||||||
}
|
}
|
||||||
} if (uid.Name.Length() >= 35 && uid.Name.SubString(0, 3) == BM_PREFIX) {
|
} if (uid.Name.Length() >= 35 && uid.Name.SubString(0, 3) == BM_PREFIX) {
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
ServerList.AddPair(BPS_BM_DEBUG_ADDRESS, BPS_DEBUG_SERVER_URL);
|
ServerList.AddPair(BPS_DEBUG_SERVER_URL, BPS_DEBUG_SERVER_URL);
|
||||||
#endif
|
#endif
|
||||||
CStringList urlList;
|
CStringList urlList;
|
||||||
if (FindURLInLine(uid.Desc, urlList)) {
|
if (FindURLInLine(uid.Desc, urlList)) {
|
||||||
@@ -345,7 +345,7 @@ namespace Apostol {
|
|||||||
|
|
||||||
auto OnDone = [this, &Context, &Provider](CTCPConnection *Sender) {
|
auto OnDone = [this, &Context, &Provider](CTCPConnection *Sender) {
|
||||||
|
|
||||||
auto pConnection = dynamic_cast<CHTTPClientConnection *> (Sender);
|
const auto pConnection = dynamic_cast<CHTTPClientConnection *> (Sender);
|
||||||
const auto &Reply = pConnection->Reply();
|
const auto &Reply = pConnection->Reply();
|
||||||
|
|
||||||
DebugReply(Reply);
|
DebugReply(Reply);
|
||||||
@@ -407,7 +407,7 @@ namespace Apostol {
|
|||||||
|
|
||||||
auto OnDone = [this, &Context, &Provider](CTCPConnection *Sender) {
|
auto OnDone = [this, &Context, &Provider](CTCPConnection *Sender) {
|
||||||
|
|
||||||
auto pConnection = dynamic_cast<CHTTPClientConnection *> (Sender);
|
const auto pConnection = dynamic_cast<CHTTPClientConnection *> (Sender);
|
||||||
const auto &Reply = pConnection->Reply();
|
const auto &Reply = pConnection->Reply();
|
||||||
|
|
||||||
DebugReply(Reply);
|
DebugReply(Reply);
|
||||||
@@ -804,7 +804,7 @@ namespace Apostol {
|
|||||||
|
|
||||||
Context.SetStatus(Context::csInitialization);
|
Context.SetStatus(Context::csInitialization);
|
||||||
|
|
||||||
auto pConnection = dynamic_cast<CHTTPClientConnection *> (AConnection);
|
const auto pConnection = dynamic_cast<CHTTPClientConnection *> (AConnection);
|
||||||
|
|
||||||
if (pConnection != nullptr) {
|
if (pConnection != nullptr) {
|
||||||
auto &Reply = pConnection->Reply();
|
auto &Reply = pConnection->Reply();
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ namespace Apostol {
|
|||||||
void UpdateServerList(TPairs<ClassName> &ClassList, const CString &Key) {
|
void UpdateServerList(TPairs<ClassName> &ClassList, const CString &Key) {
|
||||||
CStringPairs ServerList;
|
CStringPairs ServerList;
|
||||||
CStringList Keys;
|
CStringList Keys;
|
||||||
int index;
|
|
||||||
|
|
||||||
ParsePGPKey(Key, ServerList, Keys);
|
ParsePGPKey(Key, ServerList, Keys);
|
||||||
|
|
||||||
@@ -68,11 +67,8 @@ namespace Apostol {
|
|||||||
CStringPairs::ConstEnumerator em(ServerList);
|
CStringPairs::ConstEnumerator em(ServerList);
|
||||||
while (em.MoveNext()) {
|
while (em.MoveNext()) {
|
||||||
const auto &caCurrent = em.Current();
|
const auto &caCurrent = em.Current();
|
||||||
#ifndef _DEBUG
|
int index = ClassList.IndexOfName(caCurrent.Name());
|
||||||
if (caCurrent.Name() == BPS_BM_DEBUG_ADDRESS)
|
|
||||||
continue;
|
|
||||||
#endif
|
|
||||||
index = ClassList.IndexOfName(caCurrent.Name());
|
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
index = ClassList.AddPair(caCurrent.Name(), ClassName(caCurrent.Name(), CLocation(caCurrent.Value())));
|
index = ClassList.AddPair(caCurrent.Name(), ClassName(caCurrent.Name(), CLocation(caCurrent.Value())));
|
||||||
auto &Context = ClassList[index].Value();
|
auto &Context = ClassList[index].Value();
|
||||||
|
|||||||
@@ -69,13 +69,12 @@ namespace Apostol {
|
|||||||
|
|
||||||
if (m_Servers.Count() == 0) {
|
if (m_Servers.Count() == 0) {
|
||||||
#ifdef _DEBUG
|
#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();
|
auto &Keys = m_Servers[index].Value().PGP();
|
||||||
Keys.Add(CKeyContext(CString("PUBLIC"), CString()));
|
Keys.Add(CKeyContext(CString("PUBLIC"), CString()));
|
||||||
Keys.Add(CKeyContext(CString(BPS_BM_DEBUG_ADDRESS), CString()));
|
Keys.Add(CKeyContext(CString(BPS_BM_DEBUG_ADDRESS), CString()));
|
||||||
#else
|
|
||||||
m_Servers.Add(m_DefaultServer);
|
|
||||||
#endif
|
#endif
|
||||||
|
m_Servers.Add(m_DefaultServer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------
|
||||||
@@ -1111,10 +1110,10 @@ namespace Apostol {
|
|||||||
|
|
||||||
auto OnExecute = [this, &Context](CTCPConnection *AConnection) {
|
auto OnExecute = [this, &Context](CTCPConnection *AConnection) {
|
||||||
|
|
||||||
auto pConnection = dynamic_cast<CHTTPClientConnection *> (AConnection);
|
const auto pConnection = dynamic_cast<CHTTPClientConnection *> (AConnection);
|
||||||
|
|
||||||
if (pConnection != nullptr) {
|
if (pConnection != nullptr) {
|
||||||
auto pClient = dynamic_cast<CHTTPClient *> (pConnection->Client());
|
const auto pClient = dynamic_cast<CHTTPClient *> (pConnection->Client());
|
||||||
const auto &Reply = pConnection->Reply();
|
const auto &Reply = pConnection->Reply();
|
||||||
|
|
||||||
DebugReply(Reply);
|
DebugReply(Reply);
|
||||||
@@ -1163,9 +1162,9 @@ namespace Apostol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto OnException = [&Context](CTCPConnection *AConnection, const Delphi::Exception::Exception &E) {
|
auto OnException = [&Context](CTCPConnection *AConnection, const Delphi::Exception::Exception &E) {
|
||||||
auto pConnection = dynamic_cast<CHTTPClientConnection *> (AConnection);
|
const auto pConnection = dynamic_cast<CHTTPClientConnection *> (AConnection);
|
||||||
if (pConnection != nullptr) {
|
if (pConnection != nullptr) {
|
||||||
auto pClient = dynamic_cast<CHTTPClient *> (pConnection->Client());
|
const auto pClient = dynamic_cast<CHTTPClient *> (pConnection->Client());
|
||||||
if (pClient != nullptr) {
|
if (pClient != nullptr) {
|
||||||
const auto &name = pClient->Data()["name"];
|
const auto &name = pClient->Data()["name"];
|
||||||
auto &Keys = Context.PGP();
|
auto &Keys = Context.PGP();
|
||||||
@@ -1198,7 +1197,7 @@ namespace Apostol {
|
|||||||
Key.StatusTime = Now();
|
Key.StatusTime = Now();
|
||||||
Key.RunTime = Key.StatusTime;
|
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);
|
pClient->Data().AddPair("name", Key.Name);
|
||||||
|
|
||||||
@@ -1249,10 +1248,7 @@ namespace Apostol {
|
|||||||
void CWebService::Heartbeat(CDateTime Now) {
|
void CWebService::Heartbeat(CDateTime Now) {
|
||||||
for (int i = 0; i < m_Servers.Count(); i++) {
|
for (int i = 0; i < m_Servers.Count(); i++) {
|
||||||
auto &Context = m_Servers[i].Value();
|
auto &Context = m_Servers[i].Value();
|
||||||
#ifndef _DEBUG
|
|
||||||
if (Context.Name() == BPS_BM_DEBUG_ADDRESS)
|
|
||||||
continue;
|
|
||||||
#endif
|
|
||||||
if (Now >= Context.CheckDate()) {
|
if (Now >= Context.CheckDate()) {
|
||||||
Context.SetCheckDate(Now + (CDateTime) 30 / SecsPerDay); // 30 sec
|
Context.SetCheckDate(Now + (CDateTime) 30 / SecsPerDay); // 30 sec
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ namespace Apostol {
|
|||||||
|
|
||||||
if (m_Servers.Count() == 0) {
|
if (m_Servers.Count() == 0) {
|
||||||
#ifdef _DEBUG
|
#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();
|
auto &Keys = m_Servers[index].Value().PGP();
|
||||||
Keys.Add(CKeyContext(CString("PUBLIC"), CString()));
|
Keys.Add(CKeyContext(CString("PUBLIC"), CString()));
|
||||||
Keys.Add(CKeyContext(CString(BPS_BM_DEBUG_ADDRESS), CString()));
|
Keys.Add(CKeyContext(CString(BPS_BM_DEBUG_ADDRESS), CString()));
|
||||||
@@ -139,7 +139,7 @@ namespace Apostol {
|
|||||||
|
|
||||||
CWebSocketClient *CWebSocketModule::GetConnectedClient(const CClientContext &Context) {
|
CWebSocketClient *CWebSocketModule::GetConnectedClient(const CClientContext &Context) {
|
||||||
for (int i = 0; i < Context.ClientManager().Count(); i++) {
|
for (int i = 0; i < Context.ClientManager().Count(); i++) {
|
||||||
auto pClient = Context.ClientManager()[i];
|
const auto pClient = Context.ClientManager()[i];
|
||||||
if (pClient->Connected())
|
if (pClient->Connected())
|
||||||
return pClient;
|
return pClient;
|
||||||
}
|
}
|
||||||
@@ -154,8 +154,8 @@ namespace Apostol {
|
|||||||
while (index < m_Servers.Count()) {
|
while (index < m_Servers.Count()) {
|
||||||
const auto &caContext = m_Servers[index].Value();
|
const auto &caContext = m_Servers[index].Value();
|
||||||
if (caContext.Status() == Context::csRunning) {
|
if (caContext.Status() == Context::csRunning) {
|
||||||
if (Params.IsEmpty() || Params == caContext.URL().Origin()) {
|
if (Params.IsEmpty() || Params == caContext.Name() || Params == caContext.URL().Origin()) {
|
||||||
auto pClient = GetConnectedClient(caContext);
|
const auto pClient = GetConnectedClient(caContext);
|
||||||
if (pClient != nullptr)
|
if (pClient != nullptr)
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
@@ -1111,10 +1111,7 @@ namespace Apostol {
|
|||||||
void CWebSocketModule::Heartbeat(CDateTime Now) {
|
void CWebSocketModule::Heartbeat(CDateTime Now) {
|
||||||
for (int i = 0; i < m_Servers.Count(); i++) {
|
for (int i = 0; i < m_Servers.Count(); i++) {
|
||||||
auto &Context = m_Servers[i].Value();
|
auto &Context = m_Servers[i].Value();
|
||||||
#ifndef _DEBUG
|
|
||||||
if (Context.Name() == BPS_BM_DEBUG_ADDRESS)
|
|
||||||
continue;
|
|
||||||
#endif
|
|
||||||
if (Now >= Context.CheckDate()) {
|
if (Now >= Context.CheckDate()) {
|
||||||
Context.SetCheckDate(Now + (CDateTime) 30 / SecsPerDay); // 30 sec
|
Context.SetCheckDate(Now + (CDateTime) 30 / SecsPerDay); // 30 sec
|
||||||
|
|
||||||
@@ -1136,7 +1133,7 @@ namespace Apostol {
|
|||||||
|
|
||||||
if (Context.Status() == Context::csRunning) {
|
if (Context.Status() == Context::csRunning) {
|
||||||
for (int j = 0; j < Context.ClientManager().Count(); ++j) {
|
for (int j = 0; j < Context.ClientManager().Count(); ++j) {
|
||||||
auto pClient = Context.ClientManager()[j];
|
const auto pClient = Context.ClientManager()[j];
|
||||||
|
|
||||||
if (!pClient->Active())
|
if (!pClient->Active())
|
||||||
pClient->Active(true);
|
pClient->Active(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user