IM/MP/Response.cpp

42 lines
989 B
C++

//
// Created by dongl on 23-4-21.
//
#include "Response.h"
Response::Response(mp::MP_TYPE type, mp::MP_SRI code, const std::string &username, const std::string &msg, const std::string &token) :
Mph(type),
Sri(code, username, msg, token) {
}
Response::~Response() {
delete response;
}
void Response::init() {
response = new mp::response();
response->set_allocated_sri(sri);
mph->set_mpb_size( response->ByteSizeLong());
}
std::string Response::packet () {
init();
std::string temp;
temp.push_back(mph->ByteSizeLong());
std::cout << temp << std::endl;
mph->AppendToString(&temp);
std::cout << temp << std::endl;
response->AppendToString(&temp);
std::cout << temp << std::endl;
printf("h size: %zu\n", mph->ByteSizeLong());
printf("b size: %hhu\n", mph->mpb_size());
printf("total size: %zu\n", 1 + mph->ByteSizeLong() + mph->mpb_size());
printf("str size: %zu\n", temp.size());
return temp;
}