mmehr2 / Msw4

Source code for MagicScroll for Windows (basic) project.
0 stars 0 forks source link

Use of time stamps from Pubnub #12

Closed mmehr2 closed 6 years ago

mmehr2 commented 6 years ago

Turns out these "precision Unix epoch timestamps from the server" are just 7 more digits (nsec precision) than the usual number of seconds used by mktime() family. (So, hundreds of nsec.)

Here is a great article on c++ algorithms to convert. Howard Hennant rocks this! https://stackoverflow.com/questions/7960318/math-to-convert-seconds-since-1970-into-date-and-vice-versa/32158604#32158604

mmehr2 commented 6 years ago

The issue was about when these do and don't appear in a context. Subscribe successes update the received token, but publish successes do not. Therefore, we need to capture a time reference with pubnub_time(), a separate transaction type. I did this, and now the code is able to time-ref publishes back to the most recent server time report. I also added local timestamping, and this is used mostly in the pubnub callback function.