/* * ===================================================================================== * * Filename: proto.cpp * * Description: * * Version: 1.0 * Created: 2021年04月07日 17时04分36秒 * Revision: none * Compiler: gcc * * Author: Li Chao (), lichao@aiotlink.com * Organization: * * ===================================================================================== */ #include "proto.h" #include std::string RandId() { boost::uuids::uuid id = boost::uuids::random_generator()(); return std::string((char *) &id, sizeof(id)); } BHMsgHead InitMsgHead(const MsgType type, const std::string &proc_id) { return InitMsgHead(type, proc_id, RandId()); } BHMsgHead InitMsgHead(const MsgType type, const std::string &proc_id, const std::string &msgid) { BHMsgHead msg; msg.set_msg_id(msgid); msg.set_type(type); msg.set_proc_id(proc_id); time_t tm = 0; msg.set_timestamp(time(&tm)); return msg; }