#include "userauth.pb.h"
发送:
PB::MSGCARRIER::MsgCarrier MA;
PB::USERAUTH::UserAuth umsg; umsg.set_username("admin"); umsg.set_password("admin"); MA.set_message(umsg.SerializeAsString()); MA.set_type(PB::MSGCARRIER::MsgCarrier_MsgType_USERAUTH); const string& msg = MA.SerializeAsString();
接收:
PB::MSGCARRIER::MsgCarrier MA;
PB::USERAUTH::UserAuth UA; MA.ParseFromString(msgParts); UA.ParseFromString(MA.message());
相关文件
msgcarrier.proto
typedef.proto
userauth.proto