上次提交的问题修改成功 mph->set_mpb_size(request->ByteSizeLong());
This commit is contained in:
@@ -55,6 +55,7 @@ int main(int argc, char **argv) {
|
||||
auto request = new Request(mp::MP_REQUEST_LOGIN, mp::MP_REQUEST_LOGIN_ACCOUNT, "783556037", "Aa316216");
|
||||
auto packet = request->packet();
|
||||
|
||||
bufferevent_write(bev, packet.c_str(), packet.size());
|
||||
bufferevent_write(bev, packet.c_str(), packet.size());
|
||||
|
||||
delete request;
|
||||
@@ -68,18 +69,6 @@ int main(int argc, char **argv) {
|
||||
char b[257];
|
||||
strncpy(b, packet.c_str() + strlen(h), packet.size() - strlen(h));
|
||||
|
||||
auto mph = new mp::mph();
|
||||
mph->ParseFromString(h);
|
||||
printf("h size: %hhu\n", l);
|
||||
printf("b size: %hhu\n", mph->mpb_size());
|
||||
printf("total size: %hhu\n", 1 + l + mph->mpb_size());
|
||||
printf("str size: %zu\n", packet.size());
|
||||
|
||||
std::string temp;
|
||||
temp.assign(packet.c_str(), packet.length());
|
||||
printf("temp str: %s\n", packet.c_str());
|
||||
|
||||
|
||||
fflush(stdout);
|
||||
event_base_dispatch(base);
|
||||
event_base_free(base);
|
||||
|
||||
@@ -24,7 +24,7 @@ void Request::init() {
|
||||
request = new mp::request();
|
||||
request->set_allocated_body(body);
|
||||
request->set_allocated_cqi(cqi);
|
||||
mph->set_mpb_size(body->ByteSizeLong() + cqi->ByteSizeLong());
|
||||
mph->set_mpb_size(request->ByteSizeLong());
|
||||
}
|
||||
|
||||
std::string Request::packet() {
|
||||
@@ -32,12 +32,8 @@ std::string Request::packet() {
|
||||
std::string temp;
|
||||
|
||||
temp.push_back(mph->ByteSizeLong());
|
||||
std::cout << temp << std::endl;
|
||||
mph->AppendToString(&temp);
|
||||
std::cout << temp << std::endl;
|
||||
request->AppendToString(&temp);
|
||||
std::cout << temp << std::endl;
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,17 +24,8 @@ std::string Response::packet () {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -63,9 +63,6 @@ void management::read_packet(bufferevent *bev, sockaddr_in *addr) {
|
||||
memset(packet_h, 0, sizeof(packet_h));
|
||||
memset(packet_b, 0, sizeof(packet_b));
|
||||
|
||||
std::cout << len_index << std::endl;
|
||||
std::cout << buff << std::endl;
|
||||
|
||||
/// read L 读包长度
|
||||
uint8_t packetLen;
|
||||
// 取包长度
|
||||
@@ -95,8 +92,6 @@ void management::read_packet(bufferevent *bev, sockaddr_in *addr) {
|
||||
// 更新buffer长度
|
||||
len_index -= mph->mpb_size();
|
||||
|
||||
std::cout << buff << std::endl;
|
||||
|
||||
// 请求
|
||||
auto request = analysis(mph, packet_b)(bev, addr);
|
||||
// 响应
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
#include "UserProveController.h"
|
||||
|
||||
void UserProveController::run(std::shared_ptr<agreement_request> request, std::shared_ptr<agreement_response> response) {
|
||||
printf("客户端版本:%f", request->m_cqi.cqi_version());
|
||||
printf("account:%s", request->m_body.account().c_str());
|
||||
|
||||
// 登陆
|
||||
if (request->m_mph->mp_type() == mp::MP_REQUEST_LOGIN) {
|
||||
auto sri = service.login(request->m_body.subcommand(),
|
||||
|
||||
Reference in New Issue
Block a user