Committing updates.
This commit is contained in:
@@ -964,6 +964,60 @@ namespace Apostol {
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void CWebSocketModule::DoProxy(CHTTPServerConnection *AConnection, const CString &Method, const CString &URI) {
|
||||
|
||||
auto OnRequest = [AConnection](CWebSocketMessageHandler *AHandler, CWebSocketConnection *AWSConnection) {
|
||||
auto pReply = AConnection->Reply();
|
||||
const auto &wsMessage = CCustomWebSocketClient::RequestToMessage(AWSConnection);
|
||||
pReply->ContentType = CHTTPReply::json;
|
||||
if (wsMessage.MessageTypeId == mtCallResult) {
|
||||
pReply->Content = wsMessage.Payload.ToString();
|
||||
AConnection->SendReply(CHTTPReply::ok, nullptr, true);
|
||||
} else {
|
||||
ReplyError(AConnection, CHTTPReply::bad_request, wsMessage.ErrorMessage);
|
||||
}
|
||||
};
|
||||
|
||||
auto pServerRequest = AConnection->Request();
|
||||
|
||||
const auto &caModuleAddress = m_Module["address"];
|
||||
const auto &caModuleFee = m_Module["fee"];
|
||||
|
||||
const auto checkFee = CheckFee(caModuleFee);
|
||||
if (checkFee == -1)
|
||||
throw ExceptionFrm("Invalid module fee value: %s", caModuleFee.c_str());
|
||||
|
||||
const auto &caHost = pServerRequest->Headers["host"];
|
||||
const auto &caOrigin = pServerRequest->Headers["origin"];
|
||||
|
||||
const auto &address = pServerRequest->Params["address"];
|
||||
const auto &code = pServerRequest->Params["code"];
|
||||
|
||||
const auto &caUserAddress = address.length() == 40 ? CString() : address;
|
||||
const auto &caDealCode = !code.empty() ? code : address.length() == 40 ? address : CString();
|
||||
|
||||
const auto &pgpValue = pServerRequest->Params["pgp"];
|
||||
const auto &caServerParam = pServerRequest->Params["server"];
|
||||
|
||||
const auto index = CurrentContextIndex(caServerParam);
|
||||
if (index == -1) {
|
||||
throw Delphi::Exception::Exception(NOT_FOUND_ACTIVE_CONNECTION);
|
||||
}
|
||||
|
||||
const auto &caContext = m_Servers[index].Value();
|
||||
|
||||
auto pClient = GetConnectedClient(caContext);
|
||||
|
||||
if (pClient == nullptr) {
|
||||
throw Delphi::Exception::Exception(NOT_FOUND_ACTIVE_CONNECTION);
|
||||
}
|
||||
|
||||
const CJSON Json(pServerRequest->Content);
|
||||
|
||||
pClient->Send(URI, Json, OnRequest);
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void CWebSocketModule::DoSignature(CHTTPServerConnection *AConnection) {
|
||||
auto pRequest = AConnection->Request();
|
||||
auto pReply = AConnection->Reply();
|
||||
|
||||
Reference in New Issue
Block a user