Code Monkey home page Code Monkey logo

Comments (13)

rakeshta avatar rakeshta commented on August 20, 2024

How this affects me:
I am trying to fetch full history in a channel by making multiple calls to the history API. When each history response is received i make another history request with the start date from the previous response.

Now due to this error, my history fetch is looses integrity.

from objective-c.

parfeon avatar parfeon commented on August 20, 2024

Those precision is redundant for NSDate, thats why value vas transformed into normal seconds (there is 10^7 extra length which is not even unix timestamp)

from objective-c.

geremyCohen avatar geremyCohen commented on August 20, 2024

@rakeshta alternatively, cant you use:

+ (void)requestFullHistoryForChannel:(PNChannel *)channel;  
+ (void)requestFullHistoryForChannel:(PNChannel *)channel   
    withCompletionBlock:(PNClientHistoryLoadHandlingBlock)handleBlock;

To pull full history?

from objective-c.

parfeon avatar parfeon commented on August 20, 2024

But @rakeshta is correct about that raw time token for corresponding objects is required.

from objective-c.

rakeshta avatar rakeshta commented on August 20, 2024

@geremyCohen requestFullHistoryForChannel: will only fetch the 100 most recent messages. Apparently this is a limit in your REST API. (I verified this by invoking your API without the limit query param.)
So to fetch full history, I have to make multiple history requests using the date range from the previous history result as the input for the next query. (This is exactly how the dev console on your website does it)

from objective-c.

rakeshta avatar rakeshta commented on August 20, 2024

@parfeon perhaps NSDate is not the right data structure to pass these time tokens around? (You could have your own PNTime or something)

from objective-c.

rakeshta avatar rakeshta commented on August 20, 2024

Here's the fix:
PNMacro.h
Replace line 157

-        timeStamp = longLongValue/10000000;

with

+        timeStamp = (NSTimeInterval)longLongValue/10000000;
 static NSTimeInterval PNUnixTimeStampFromTimeToken(NSNumber *timeToken);
 NSTimeInterval PNUnixTimeStampFromTimeToken(NSNumber *timeToken) {

     unsigned long long int longLongValue = [timeToken unsignedLongLongValue];
     NSTimeInterval timeStamp = longLongValue;
     if (longLongValue > INT32_MAX) {

        timeStamp = (NSTimeInterval)longLongValue/10000000;
     }


     return timeStamp;
 }

from objective-c.

rakeshta avatar rakeshta commented on August 20, 2024

There's still a minute accuracy error when converting between unsigned long long int and NSTimeInterval. But its way better than when all sub second information was getting lost.

from objective-c.

geremyCohen avatar geremyCohen commented on August 20, 2024

Thanks @rakeshta ! We'll review this and queue it for master merge.

from objective-c.

parfeon avatar parfeon commented on August 20, 2024

Hi @rakeshta
I modified PubNub sources and added custom date object (as you suggested it is PNDate) and it has two methods: date (which will return NSDate) and timeToken (which will return NSNumber with unsigned long long integer in it as number arrived in response)

from objective-c.

rakeshta avatar rakeshta commented on August 20, 2024

@parfeon; That is awesome. thanks!

from objective-c.

geremyCohen avatar geremyCohen commented on August 20, 2024

@parfeon, thanks for the quick action! and @rakeshta, thanks for helping us make the client even better!

from objective-c.

geremyCohen avatar geremyCohen commented on August 20, 2024

@rakeshta if you can clone local, and merge master into this branch for now, I will be merging it into master by end of week for production use.

from objective-c.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.