| | |
| | | */ |
| | | #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) |
| | | { |
| | |
| | | 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; |
| | | } |