From d209bb23c7d6d5b9f6afaeba7a2c91ab9dc6ad36 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 11 Dec 2019 17:24:33 +0800 Subject: [PATCH] 1 --- cpp/protoutils.cc | 16 ++++++++++++++++ cpp/protoutils.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/cpp/protoutils.cc b/cpp/protoutils.cc index 92ea9b1..f9c8ce2 100644 --- a/cpp/protoutils.cc +++ b/cpp/protoutils.cc @@ -116,6 +116,22 @@ namespace f8 return sizeof(PackHead) + packlen; } + int Net_SendMsgOld(a8::TcpClient* tcp_client, unsigned int seqid, + unsigned short msgid, ::google::protobuf::Message& msg) + { + int packlen = msg.ByteSize(); + + char* buff = (char*)malloc(sizeof(f8::PackHeadOld) + packlen); + f8::PackHeadOld* head = (f8::PackHeadOld*)buff; + head->packlen = packlen; + head->msgid = msgid; + head->magiccode = MAGIC_CODE; + msg.SerializeToArray(buff + sizeof(f8::PackHeadOld), packlen); + tcp_client->SendBuff(buff, sizeof(f8::PackHeadOld) + packlen); + free(buff); + return sizeof(f8::PackHeadOld) + packlen; + } + int Net_SendMsg(a8::TcpClient2* tcp_client, unsigned seqid, unsigned short msgid, ::google::protobuf::Message& msg) { diff --git a/cpp/protoutils.h b/cpp/protoutils.h index 9ae91b7..170c17f 100644 --- a/cpp/protoutils.h +++ b/cpp/protoutils.h @@ -108,6 +108,8 @@ namespace f8 void Net_PackMsgOld(unsigned short msgid, ::google::protobuf::Message& msg, std::string& out); int Net_SendMsg(a8::TcpClient* tcp_client, unsigned int seqid, unsigned short msgid, ::google::protobuf::Message& msg); + int Net_SendMsgOld(a8::TcpClient* tcp_client, unsigned int seqid, + unsigned short msgid, ::google::protobuf::Message& msg); int Net_SendMsg(a8::TcpClient2* tcp_client, unsigned int seqid, unsigned short msgid, ::google::protobuf::Message& msg); int Net_SendBigMsg(a8::TcpClient* tcp_client, unsigned int seqid,