// When we receive an url response this method is called; // The loaded image is removed from the async_queue and added to the // update queue. The update queue is used to update the texture. //-------------------------------------------------------------- void ofxThreadedImageLoader::urlResponse(ofHttpResponse & response) { if(response.status == 200) { lock(); // Get the loaded url from the async queue and move it into the update queue. entry_iterator it = getEntryFromAsyncQueue(response.request.name); if(it != images_async_loading.end()) { (*it).image->loadImage(response.data); images_to_update.push_back((*it)); images_async_loading.erase(it); } unlock(); } else { // log error. stringstream ss; ss << "Could not image from url, response status: " << response.status; ofLog(OF_LOG_ERROR, ss.str()); // remove the entry from the queue lock(); entry_iterator it = getEntryFromAsyncQueue(response.request.name); if(it != images_async_loading.end()) { images_async_loading.erase(it); } else { ofLog(OF_LOG_WARNING, "Cannot find image in load-from-url queue"); } unlock(); } }
// When we receive an url response this method is called; // The loaded image is removed from the async_queue and added to the // update queue. The update queue is used to update the texture. //-------------------------------------------------------------- void ofxThreadedImageLoaderSingleton::urlResponse(ofHttpResponse & response) { if(response.status == 200) { lock(); // Get the loaded url from the async queue and move it into the update queue. entry_iterator it = getEntryFromAsyncQueue(response.request.name); if(it != images_async_loading.end()) { (*it).image->loadImage(response.data); images_to_update.push_back(*it); images_async_loading.erase(it); } unlock(); }else{ // log error. ofLogError()<< "Could not get image from url, response status: " << response.status; ofRemoveURLRequest(response.request.getID()); // remove the entry from the queue lock(); entry_iterator it = getEntryFromAsyncQueue(response.request.name); if(it != images_async_loading.end()) { images_async_loading.erase(it); } unlock(); } }