lichao
2021-04-13 7f307880a58012077833061b5ff18ba63c1a2269
src/proto.cpp
@@ -17,12 +17,18 @@
 */
#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
BHMsgHead InitMsgHead(const MsgType type, const std::string &proc_id)
{
@@ -35,7 +41,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;
}