use timeval instead of double for time sync

This commit is contained in:
badaix 2016-04-02 13:22:08 +02:00
parent 6ea10c77dd
commit 14b5abe5d7
6 changed files with 21 additions and 15 deletions

View file

@ -26,6 +26,14 @@ TimeProvider::TimeProvider() : diffToServer_(0)
}
void TimeProvider::setDiff(const tv& c2s, const tv& s2c)
{
tv latency = c2s - s2c;
double diff = latency.sec * 1000. + latency.usec / 1000.;
setDiffToServer(diff / 2.);
}
void TimeProvider::setDiffToServer(double ms)
{
static int32_t lastTimeSync = 0;