ofxTwitter -> Threading?


I’m writing a small sentiment analysis program from ofxTwitters stream features.

Basically, the way I have it set up at the moment is that when a tweet comes in, it sends a GET request of the text to an analysis server that I have set up which returns raw JSON of valence/arousal scores, estimating the emotion conveyed within the tweet.

The problem I’m having is that in the draw() function, I’m plotting these scores as circles on a 2D axis. When I use a particularly active stream filter, the frames drop hugely. Would threading the function that handles the tweet analysis help prevent this?

At the moment, this is what I have:

void ofApp::onStatus(const ofxTwitter::Status& status)
string txt = status.text();
ofApp::find_and_replace(txt, " ", “%20”);
Tweet tweet;
tweet.text = txt;
bool parsingSuccessful = result.open(urlHeader+ txt +urlFooter);

if (parsingSuccessful)
    tweet.rawJSON = result;
    ofLogNotice("ofApp::setup")  << "Failed to parse JSON" << endl;


The draw() function loops through the tweets vector, drawing circles based on the parsed JSON values returned.