Distribution_Service/Server/PortService/R_Order_AB.h

128 lines
4.5 KiB
C
Raw Normal View History

2025-12-03 18:08:23 +08:00
#ifndef OH_BS_R_ORDER_AB_H
#define OH_BS_R_ORDER_AB_H
#include "DataPacket.h"
#include "ByteTool.h"
#include "../Configuration/BS_Log.h"
2025-12-04 18:12:54 +08:00
#include "Task/TaskInfo.h"
2025-12-03 18:08:23 +08:00
#include "Terminal/Terminal.h"
class R_Order_AB {
public:
static void Function(const DataPacket& packet){
const auto N = packet.FunNumber.get();
const auto hex = APPTool::GetHX(N);
const auto str = CC::format("RoutingAB::Function(%s)", hex.c_str());
BS_Log::Log(str);
}
static void Function_0x02(const DataPacket& packet){
const auto Setting = Config::getConfig();
const auto ID = APPTool::GetInt(packet.Parameter2, packet.Parameter3);
if (packet.Parameter1 == 0x00) {
}
else if (packet.Parameter1 == 0x01) {
Setting->ID = ID;
BS_Log::Log("Function_0x02 ID Change to {}", ID);
}
const auto IDS = APPTool::GetBytes(Setting->ID);
2025-12-04 18:12:54 +08:00
const CTL::ByteArray data = {0x66,0xAB,0x09,0x00,IDS[0],IDS[1],0x00,0x00};
if (packet.AimWS && packet.IsTCP) {
2025-12-03 18:08:23 +08:00
packet.AimWS->SendBinary(data);
}
}
static void Function_0x03(const DataPacket& packet){
const auto Setting = Config::getConfig();
const auto str = Terminal::toTermInfo();
const auto IDS = APPTool::GetBytes(Setting->ID);
const auto Len = APPTool::GetBytes(str.size());
CTL::ByteArray data = {0x66,0xAB,0x03,0x00,IDS[0],IDS[1],Len[0],Len[1]};
data.append(str);
if (packet.IsTCP && packet.AimWS) {
packet.AimWS->SendBinary(data);
}
}
static void Function_0x04(const DataPacket& packet){
}
static void Function_0x05(const DataPacket& packet){
}
static void Function_0x06(const DataPacket& packet) {
}
2025-12-04 18:12:54 +08:00
static void Function_0x07(const DataPacket& packet) {
try {
const auto ID = APPTool::GetInt(packet.Parameter2, packet.Parameter3);
const int TaskID = packet.Parameter1;
const int Length = APPTool::GetInt(packet.Parameter4, packet.Parameter5);
const auto str = packet.AdditionalData.toString();
CTL::JSONObject Json = CTL::JSONObject::parse(str);
const int Flag = Json.get("Flag");
if (Flag == 1) {
const auto taskInfo = new TaskInfo;
taskInfo->TaskID = TaskID;
taskInfo->TaskType = Json.get("TaskType");
taskInfo->ServerPort = Json.get("ServerPort");
const auto TermList = Json.get("Terms").get<CCVector<int>>();
for (const auto& TID : TermList) {
taskInfo->Terms.put(TID, TID);
}
taskInfo->pushFlowTask = new PushFlowTask(TaskID);
TaskInfo::Start(taskInfo);
taskInfo->pushFlowTask->start();
}
else if (Flag == 0) {
const auto taskInfo = TaskInfo::getData(TaskID);
if (taskInfo) {
if (taskInfo->Type == 0 && taskInfo->pushFlowTask) {
taskInfo->pushFlowTask->stop();
}
}
TaskInfo::Stop(TaskID);
}
}
catch (CCException& e) {
BS_Log::Error("Function_0x07 Error: {}",e.what());
}
2025-12-03 18:08:23 +08:00
}
2025-12-04 18:12:54 +08:00
static void Function_0x09(const DataPacket& packet) {
try {
const auto str = packet.AdditionalData.toString();
CTL::JSONObject Json = CTL::JSONObject::parse(str);
const auto taskInfo = new TaskInfo;
taskInfo->TaskID = Json.get("TaskID");
taskInfo->TaskType = Json.get("TaskType");
taskInfo->ServerPort = Json.get("ServerPort");
const auto TermList = Json.get("Terms").get<CCVector<int>>();
for (const auto& TID : TermList) {
taskInfo->Terms.put(TID, TID);
}
taskInfo->pushFlowTask = new PushFlowTask(taskInfo->TaskID);
TaskInfo::Start(taskInfo);
taskInfo->pushFlowTask->start();
}
catch (CCException& e) {
BS_Log::Error("Function_0x09 Error: {}",e.what());
}
}
static void Function_0x10(const DataPacket& packet) {
try {
2025-12-03 18:08:23 +08:00
2025-12-04 18:12:54 +08:00
}
catch (CCException& e) {
BS_Log::Error("Function_0x10 Error: {}",e.what());
}
2025-12-03 18:08:23 +08:00
}
2025-12-04 18:12:54 +08:00
static void Function_0x11(const DataPacket& packet) {
try {
}
catch (CCException& e) {
BS_Log::Error("Function_0x11 Error: {}",e.what());
}
2025-12-03 18:08:23 +08:00
}
};
#endif