diff --git a/Sys.cpp b/Sys.cpp index 51d08921..8e74eddd 100644 --- a/Sys.cpp +++ b/Sys.cpp @@ -483,6 +483,8 @@ void TimeSleep(uint us) // 系统启动后的毫秒数 ulong TSys::Ms() { return Time.Current(); } +// 系统绝对当前时间,秒 +uint TSys::Seconds() { return Time.Seconds + Time.BaseSeconds; } void TSys::Sleep(uint ms) { diff --git a/Sys.h b/Sys.h index 72093388..dfcbf1f6 100644 --- a/Sys.h +++ b/Sys.h @@ -96,6 +96,7 @@ public: uint StackTop(); // 栈顶,后面是初始化不清零区域 ulong Ms(); // 系统启动后的毫秒数 + uint Seconds(); // 系统绝对当前时间,秒 void Sleep(uint ms); // 毫秒级延迟 void Delay(uint us); // 微秒级延迟 diff --git a/TinyNet/TinyServer.cpp b/TinyNet/TinyServer.cpp index d1d946e3..ae60aff2 100644 --- a/TinyNet/TinyServer.cpp +++ b/TinyNet/TinyServer.cpp @@ -374,7 +374,7 @@ bool TinyServer::OnPing(const TinyMessage& msg) // 0x02给客户端同步时间,4字节的秒 auto ms2 = rs.ToStream(); - pm.WriteTime(ms2, Sys.Ms() / 1000); + pm.WriteTime(ms2, Sys.Seconds()); Reply(rs); diff --git a/TokenNet/TokenClient.cpp b/TokenNet/TokenClient.cpp index 7195a418..fcac3d42 100644 --- a/TokenNet/TokenClient.cpp +++ b/TokenNet/TokenClient.cpp @@ -397,16 +397,6 @@ bool TokenClient::OnPing(TokenMessage& msg, Controller* ctrl) Delay = cost; debug_printf("心跳延迟 %dms / %dms \r\n", cost, Delay); -#if DEBUG - debug_printf("start: "); - DateTime dt(start / 1000); - dt.Show(); - debug_printf("\r\n"); - debug_printf("TimeNow: "); - DateTime dt2(Sys.Ms() / 1000); - dt2.Show(); - debug_printf("\r\n"); -#endif return true; }