1
This commit is contained in:
parent
e8e6a85b8f
commit
8a49aa65c8
@ -92,6 +92,24 @@ namespace f8
|
||||
return sizeof(PackHead) + packlen;
|
||||
}
|
||||
|
||||
int Net_SendMsg(a8::AsioTcpClient* tcp_client, unsigned seqid, unsigned short msgid,
|
||||
const ::google::protobuf::Message& msg)
|
||||
{
|
||||
int packlen = msg.ByteSize();
|
||||
|
||||
char* buff = (char*)malloc(sizeof(PackHead) + packlen);
|
||||
PackHead* head = (PackHead*)buff;
|
||||
head->packlen = packlen;
|
||||
head->msgid = msgid;
|
||||
head->seqid = seqid;
|
||||
head->magic_code = MAGIC_CODE;
|
||||
head->ext_len = packlen >> 16;
|
||||
msg.SerializeToArray(buff + sizeof(PackHead), packlen);
|
||||
tcp_client->SendBuff(buff, sizeof(PackHead) + packlen);
|
||||
free(buff);
|
||||
return sizeof(PackHead) + packlen;
|
||||
}
|
||||
|
||||
int Net_SendBigMsg(a8::TcpClient* tcp_client, unsigned seqid, unsigned short msgid,
|
||||
::google::protobuf::Message& msg)
|
||||
{
|
||||
|
@ -89,6 +89,8 @@ namespace f8
|
||||
void Net_PackMsg(unsigned short msgid, ::google::protobuf::Message& msg, std::string& out);
|
||||
int Net_SendMsg(a8::TcpClient* tcp_client, unsigned int seqid,
|
||||
unsigned short msgid, const ::google::protobuf::Message& msg);
|
||||
int Net_SendMsg(a8::AsioTcpClient* tcp_client, unsigned int seqid,
|
||||
unsigned short msgid, const ::google::protobuf::Message& msg);
|
||||
int Net_SendBigMsg(a8::TcpClient* tcp_client, unsigned int seqid,
|
||||
unsigned short msgid, ::google::protobuf::Message& msg);
|
||||
int Net_SendMsg(a8::TcpClient* tcp_client, unsigned int seqid, unsigned short msgid,
|
||||
|
Loading…
x
Reference in New Issue
Block a user