lichao
2021-04-16 c6964d5af25d4ec7ed9dbe7674dc4e3896b36ead
src/proto.cpp
@@ -17,12 +17,20 @@
 */
#include "proto.h"
#include <boost/uuid/uuid_generators.hpp>
#include <chrono>
namespace
{
std::string RandId()
{
   boost::uuids::uuid id = boost::uuids::random_generator()();
   return std::string((char *) &id, sizeof(id));
}
} // namespace
std::string NewMsgId() { return RandId(); }
BHMsgHead InitMsgHead(const MsgType type, const std::string &proc_id)
{
@@ -35,7 +43,11 @@
   msg.set_msg_id(msgid);
   msg.set_type(type);
   msg.set_proc_id(proc_id);
   time_t tm = 0;
   msg.set_timestamp(time(&tm));
   msg.set_timestamp(NowSec());
   return msg;
}
bool IsMsgExpired(const BHMsgHead &head)
{
   return NowSec() > head.timestamp() + 10;
}