Giter Site home page Giter Site logo

Comments (8)

nst avatar nst commented on July 19, 2024

Sure, but I need more information. What do you mean exactly by an "active" stream? Can you give an example?

from sttwitter.

inb4ohnoes avatar inb4ohnoes commented on July 19, 2024

Ok. For example the getUserStreamDelimited method may or may not be active after the app (iOS) has been revived from background. If the stream is active, then there's no need to call the rest method to backfill tweets, but if it's not active one would backfill tweets and revive the stream connection. Do you see what I mean?

from sttwitter.

nst avatar nst commented on July 19, 2024

Yes I do, thank you for explaining. The naive way to deal with this situation would be cancelling and reconnecting to the stream each time the app becomes active. It is ok for you or do you need something more sophisticated?

from sttwitter.

inb4ohnoes avatar inb4ohnoes commented on July 19, 2024

I would indeed prefer something more sophisticated since users tend to multitask around a lot. I'd prefer not to disconnect and reconnect every six times they do so in a minute.

from sttwitter.

nst avatar nst commented on July 19, 2024

You're right. So, I think you should detect lost connections in the error block and restart the request in this case only.

// ...
} errorBlock:^(NSError *error) {

    if([[error domain] isEqualToString:NSURLErrorDomain] && [error code] == NSURLErrorNetworkConnectionLost) {
        [self startStreamRequest];
    }

}];

I'm not sure we should add something specific into STTwitter, what do you think?

from sttwitter.

inb4ohnoes avatar inb4ohnoes commented on July 19, 2024

Hmm that's a good suggestion. I'll look into doing it this way. Thanks!

from sttwitter.

macinux avatar macinux commented on July 19, 2024

BTW, How to cancel the stream? Also, i wonder if there is any way to disable sending friend list every time the stream gets connected since it would be lots of overheads if we "cancelling and reconnecting to the stream each time the app becomes active:

Thanks,
James

from sttwitter.

inb4ohnoes avatar inb4ohnoes commented on July 19, 2024

Make an STHTTPRequest object somewhere like your session manager and such. When you initialize the stream, set the stream to your object like so:

_userStream = [api getUserStreamDelimited:...

When you need to disconnect the stream, simply [_userStream cancel]. To reconnect, simply reinitialize it again like above. It's that easy! Thanks @nst for making such an easy to use library.

Also, the friends list is received every single time you start the stream. There's no way to disable it as far as I know.

from sttwitter.

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.