43 lines
969 B
C++
43 lines
969 B
C++
//
|
|
// Created by dongl on 23-4-21.
|
|
//
|
|
|
|
#include "Request.h"
|
|
|
|
Request::Request(mp::MP_TYPE type, uint64_t account, const std::string& password) :
|
|
Mph(type), Body(account, password), Cqi() {
|
|
|
|
}
|
|
|
|
Request::Request(mp::MP_TYPE type, uint64_t target, uint64_t source, const std::string& data) :
|
|
Mph(type), Body(target, source, data), Cqi() {
|
|
|
|
}
|
|
|
|
|
|
void Request::init() {
|
|
memset(temp, 0 , 256);
|
|
request = new mp::request();
|
|
request->set_allocated_body(body);
|
|
request->set_allocated_cqi(cqi);
|
|
mph->set_mpb_size(body->ByteSizeLong() + cqi->ByteSizeLong());
|
|
}
|
|
|
|
std::string Request::operator()() {
|
|
init();
|
|
std::string temp_mph;
|
|
std::string temp_request;
|
|
mph->SerializeToString(&temp_mph);
|
|
request->SerializeToString(&temp_request);
|
|
|
|
auto L = (uint8_t )temp_mph.size();
|
|
sprintf(temp, "%c", L);
|
|
sprintf(temp, "%s%s%s", temp, temp_mph.c_str(), temp_request.c_str());
|
|
return temp;
|
|
}
|
|
|
|
Request::~Request() {
|
|
delete request;
|
|
}
|
|
|