Committing updates.

This commit is contained in:
Преподобный Ален
2022-07-03 18:01:40 +03:00
parent 024103ff93
commit fd24410ee4
6 changed files with 928 additions and 50 deletions

View File

@@ -42,14 +42,6 @@ namespace Apostol {
namespace Module {
CString to_string(unsigned long Value) {
TCHAR szString[_INT_T_LEN + 1] = {0};
sprintf(szString, "%lu", Value);
return {szString};
}
//--------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------
//-- CWebService -----------------------------------------------------------------------------------------------
@@ -487,7 +479,7 @@ namespace Apostol {
}
//--------------------------------------------------------------------------------------------------------------
void CWebService::DoUser(CHTTPServerConnection *AConnection, const CString& Method, const CString& URI) {
void CWebService::DoAccount(CHTTPServerConnection *AConnection, const CString& Method, const CString& URI) {
auto pProxy = GetProxy(AConnection);
auto pServerRequest = AConnection->Request();
@@ -679,8 +671,8 @@ namespace Apostol {
}
}
//DebugMessage("[DoUser] Server request:\n%s\n", pServerRequest->Content.c_str());
//DebugMessage("[DoUser] sPayload:\n%s\n", sPayload.c_str());
//DebugMessage("[DoAccount] Server request:\n%s\n", pServerRequest->Content.c_str());
//DebugMessage("[DoAccount] sPayload:\n%s\n", sPayload.c_str());
CJSON Json(jvtObject);
@@ -718,6 +710,7 @@ namespace Apostol {
const auto DateTime = UTC();
const auto Date = StringToDate(Data.Date);
const auto Sum = BTCToDouble(Data.Payment.Sum);
if (Data.Order == doCreate) {
if (DateTime < Date)
@@ -1135,9 +1128,6 @@ namespace Apostol {
}
}
//DebugMessage("[DoDeal] Server request:\n%s\n", pServerRequest->Content.c_str());
//DebugMessage("[DoDeal] sPayload:\n%s\n", sPayload.c_str());
CJSON Json(jvtObject);
Json.Object().AddPair("id", ApostolUID());
@@ -1277,7 +1267,7 @@ namespace Apostol {
} else if (caCommand == "time") {
pReply->Content << "{\"serverTime\": " << to_string(MsEpoch()) << "}";
pReply->Content << "{\"serverTime\": " << ToString(MsEpoch()) << "}";
AConnection->SendReply(CHTTPReply::ok);
@@ -1285,13 +1275,13 @@ namespace Apostol {
pRequest->Content.Clear();
DoUser(AConnection, "GET", sRoute);
DoAccount(AConnection, "GET", sRoute);
} else if (caCommand == "account" && caAction == "status") {
pRequest->Content.Clear();
DoUser(AConnection, "GET", sRoute);
DoAccount(AConnection, "GET", sRoute);
} else if (caCommand == "deal" && caAction == "status") {
@@ -1428,7 +1418,7 @@ namespace Apostol {
if (caCommand == "account") {
DoUser(AConnection, "POST", sRoute);
DoAccount(AConnection, "POST", sRoute);
} else if (caCommand == "deal") {
@@ -1709,6 +1699,13 @@ namespace Apostol {
}
//--------------------------------------------------------------------------------------------------------------
CString CWebService::ToString(unsigned long Value) {
TCHAR szString[_INT_T_LEN + 1] = {0};
sprintf(szString, "%lu", Value);
return { szString };
}
//--------------------------------------------------------------------------------------------------------------
}
}
}

View File

@@ -81,7 +81,7 @@ namespace Apostol {
static void CheckKeyForNull(LPCTSTR Key, LPCTSTR Value);
void DoUser(CHTTPServerConnection *AConnection, const CString &Method, const CString &URI);
void DoAccount(CHTTPServerConnection *AConnection, const CString &Method, const CString &URI);
void DoDeal(CHTTPServerConnection *AConnection, const CString &Method, const CString &URI, const CString &Action);
void DoSignature(CHTTPServerConnection *AConnection);
@@ -114,6 +114,8 @@ namespace Apostol {
void Reload();
static CString ToString(unsigned long Value);
static void JsonStringToKey(const CString& jsonString, CString& Key);
static void CheckDeal(const CDeal& Deal);

File diff suppressed because it is too large Load Diff

View File

@@ -67,6 +67,8 @@ namespace Apostol {
class CWebSocketModule: public CApostolModule {
private:
CStringList m_Module;
int m_SyncPeriod;
CClientContextPair m_DefaultServer { BPS_BM_SERVER_ADDRESS, CClientContext(CLocation(BPS_SERVER_URL)) };
@@ -92,7 +94,7 @@ namespace Apostol {
void Heartbeat(CDateTime Now) override;
void DoUser(CHTTPServerConnection *AConnection, const CString &Method, const CString &URI);
void DoAccount(CHTTPServerConnection *AConnection, const CString &Method, const CString &URI);
void DoDeal(CHTTPServerConnection *AConnection, const CString &Method, const CString &URI, const CString &Action);
void DoSignature(CHTTPServerConnection *AConnection);
@@ -132,6 +134,11 @@ namespace Apostol {
bool Enabled() override;
static CString ToString(unsigned long Value);
static int CheckFee(const CString& Fee);
static void CheckDeal(const CDeal& Deal);
static void CheckKeyForNull(LPCTSTR key, const CString& Value);
static bool FindURLInLine(const CString &Line, CStringList &List);
static void LoadOAuth2(const CString &FileName, const CString &ProviderName, const CString &ApplicationName, CProviders &Providers);
};

View File

@@ -170,7 +170,7 @@ namespace Apostol {
}
//--------------------------------------------------------------------------------------------------------------
void CWebSocketClient::Send(const CString &Action, const CString &Payload, COnMessageHandlerEvent &&Handler) {
void CWebSocketClient::Send(const CString &Action, const CJSON &Payload, COnMessageHandlerEvent &&Handler) {
auto OnRequest = [this](CWebSocketMessageHandler *AHandler, CWebSocketConnection *AWSConnection) {
const auto &wsMessage = RequestToMessage(AWSConnection);

View File

@@ -90,7 +90,7 @@ namespace Apostol {
void Subscribe();
void UpdateKey();
void Send(const CString &Action, const CString &Payload, COnMessageHandlerEvent &&Handler = nullptr);
void Send(const CString &Action, const CJSON &Payload, COnMessageHandlerEvent &&Handler = nullptr);
void Reload();
@@ -151,6 +151,9 @@ namespace Apostol {
CWebSocketClientItem *Add(CContext *Context, const CLocation &URI);
CWebSocketClientItem *First() const { return GetItem(0); };
CWebSocketClientItem *Last() const { return GetItem(GetCount() - 1); };
CWebSocketClientItem *Items(int Index) const override { return GetItem(Index); };
CWebSocketClientItem *operator[] (int Index) const override { return Items(Index); };