RecvContext增加微秒接口,Current精确接收时间

This commit is contained in:
wuxf 2023-02-24 17:22:12 +08:00 committed by ruanshudong
parent 83d6195935
commit af41549b63
2 changed files with 6 additions and 5 deletions

View File

@ -128,8 +128,8 @@ int Current::getMessageType() const
struct timeval Current::getRecvTime() const struct timeval Current::getRecvTime() const
{ {
timeval tm; timeval tm;
tm.tv_sec = _data->recvTimeStamp() / 1000; tm.tv_sec = _data->recvTimeStampUs() / 1000000;
tm.tv_usec = (_data->recvTimeStamp() % 1000) * 1000; tm.tv_usec = _data->recvTimeStampUs() % 1000000;
return tm; return tm;
} }

View File

@ -187,7 +187,7 @@ public:
, _adapter(adapter) , _adapter(adapter)
, _isClosed(isClosed) , _isClosed(isClosed)
, _closeType(closeType) , _closeType(closeType)
, _recvTimeStamp(TNOWMS) , _recvTimeStamp(TNOWUS)
{} {}
inline int threadIndex() const { return _threadIndex; } inline int threadIndex() const { return _threadIndex; }
inline uint32_t uid() const { return _uid; } inline uint32_t uid() const { return _uid; }
@ -196,7 +196,8 @@ public:
inline uint16_t port() const { parseIpPort(); return _port; } inline uint16_t port() const { parseIpPort(); return _port; }
inline vector<char> & buffer() { return _rbuffer; } inline vector<char> & buffer() { return _rbuffer; }
inline const vector<char> & buffer() const { return _rbuffer; } inline const vector<char> & buffer() const { return _rbuffer; }
inline int64_t recvTimeStamp() const { return _recvTimeStamp; } inline int64_t recvTimeStamp() const { return _recvTimeStamp/1000; }
inline int64_t recvTimeStampUs() const { return _recvTimeStamp; }
inline bool isOverload() const { return _isOverload; } inline bool isOverload() const { return _isOverload; }
inline void setOverload() { _isOverload = true; } inline void setOverload() { _isOverload = true; }
inline bool isClosed() const { return _isClosed; } inline bool isClosed() const { return _isClosed; }
@ -232,7 +233,7 @@ public:
bool _isOverload = false; /**是否已过载 */ bool _isOverload = false; /**是否已过载 */
bool _isClosed = false; /**是否已关闭*/ bool _isClosed = false; /**是否已关闭*/
int _closeType; /*如果是关闭消息包,则标识关闭类型,0:表示客户端主动关闭1:服务端主动关闭;2:连接超时服务端主动关闭*/ int _closeType; /*如果是关闭消息包,则标识关闭类型,0:表示客户端主动关闭1:服务端主动关闭;2:连接超时服务端主动关闭*/
int64_t _recvTimeStamp; /**接收到数据的时间*/ int64_t _recvTimeStamp; /**接收到数据的时间,微秒*/
}; };
/** /**