增加ACE安全测试工程
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
#include "stdafx.h"
|
||||
#include "AceReportInterface.h"
|
||||
#include "GameProto.h"
|
||||
#include "GameProto.pb.h"
|
||||
#include "GameClient.h"
|
||||
|
||||
struct ACEReportStruct
|
||||
{
|
||||
int32_t id;
|
||||
Game::GameReportReq reportRequest;
|
||||
ACEReport::CallbackFunction callback;
|
||||
};
|
||||
|
||||
|
||||
ACEReport::ACEReport()
|
||||
{
|
||||
m_nextID = 1;
|
||||
}
|
||||
|
||||
ACEReport::~ACEReport()
|
||||
{
|
||||
}
|
||||
|
||||
void ACEReport::init(GameClient* client)
|
||||
{
|
||||
m_client = client;
|
||||
}
|
||||
|
||||
ACEReportContext ACEReport::createReportContext(
|
||||
const char* account,
|
||||
int32_t worldID,
|
||||
const char* reported_name,
|
||||
const char* reported_roldid,
|
||||
ACEReportScene scene,
|
||||
ACEReportCategory category,
|
||||
const ACEReportReasonArray& reasons,
|
||||
DNFReportEntranceID entranceID
|
||||
)
|
||||
{
|
||||
ACEReportStruct* ctx = new ACEReportStruct();
|
||||
ctx->id = m_nextID++;
|
||||
ctx->callback = nullptr;
|
||||
ctx->reportRequest.set_ctx_id(ctx->id);
|
||||
ctx->reportRequest.set_reported_account_id(account);
|
||||
ctx->reportRequest.set_reported_world_id(worldID);
|
||||
ctx->reportRequest.set_reported_name(reported_name);
|
||||
ctx->reportRequest.set_reported_roleid(reported_roldid);
|
||||
ctx->reportRequest.set_report_scene(static_cast<int32_t>(scene));
|
||||
ctx->reportRequest.set_report_category(static_cast<int32_t>(category));
|
||||
ctx->reportRequest.set_report_entrance(static_cast<int32_t>(entranceID));
|
||||
for(ACEReportReason reason: reasons)
|
||||
{
|
||||
ctx->reportRequest.add_report_reason(static_cast<int32_t>(reason));
|
||||
}
|
||||
|
||||
m_reportStructMap.insert(std::make_pair(ctx->id, ctx));
|
||||
return ctx;
|
||||
}
|
||||
|
||||
ACEReportStruct* ACEReport::getReport(ACEReportContext ctx)
|
||||
{
|
||||
if (ctx == nullptr) return nullptr;
|
||||
ReportStructMap::iterator it = m_reportStructMap.find(ctx->id);
|
||||
if (it == m_reportStructMap.end()) return nullptr;
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
bool ACEReport::uploadReport(ACEReportContext ctx, CallbackFunction callback)
|
||||
{
|
||||
ACEReportStruct* report = getReport(ctx);
|
||||
if (report == nullptr) return false;
|
||||
|
||||
Game::GameReportReq& reportReq = report->reportRequest;
|
||||
if(reportReq.report_reason_size() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
report->callback = callback;
|
||||
|
||||
m_client->sendProtobufMessage(GAME_PROTO_REPORT_REQ, &reportReq);
|
||||
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user