TuftEntertainment / hashtag-warrior

Open-source iOS game powered by cocos2d.
MIT License
8 stars 7 forks source link

Tweet stream, live vs cached. #15

Closed verbitan closed 11 years ago

verbitan commented 11 years ago

Ideally I'd love to have a mode in the game where tweets came in at real time, however this doesn't seem likely with the current Twitter API.

The Twitter Streaming API says...

Connections

Each account may create only one standing connection to the public endpoints, and connecting to a public stream more than once with the same account credentials will cause the oldest connection to be disconnected.

Clients which make excessive connection attempts (both successful and unsuccessful) run the risk of having their IP automatically banned

This causes us a problem, because in the best case scenario we'd keep a connection open for the duration the game is open. That still creates a new connection each time the game is reopened, Twitter will eventually block if you open a connection too often.

My solution is to use the historic API, and implement a sort of Tweet buffer... E.g load 10 minutes worth of tweets, play them back in real time, and make the class automatically request more Tweets if the player is close to exhausting the cached Tweets.

verbitan commented 11 years ago

Implemented a Tweet cache in change 0c4d2ec6cc.