我需要在 ZMQ 套接字上发送一个对象(用 GPB 序列化)。目前该代码有一个额外的副本。如何直接将序列化数组写入message_t
s数据?
ABT_CommunicationProtocol introPacket;
// Fill the packet
message_t introMessage;
size_t dataLenght = introPacket.ByteSize();
char* temp = new char[dataLenght];
introPacket.SerializeToArray(temp, dataLenght); // write data to temp
memcpy(introMessage.data(), temp, dataLenght); // copy data to message
this->serverRquest.send(introMessage);