Beispiel #1
0
/**
* Effectue la requete
*/
void http::runRequest(const char* page, int assync) {
	_page = page;
	_status = ST_PENDING;
	_assync = (AssyncMode)assync;
	_progressValue = 0;
	
	std::string url = cross_domain;
	url += _hostname + _page;
	
	if (_hostname.size() > 0  && _page.size() > 0) {
	
		printf("URL : %s\n",url.c_str());
		printf("REQUEST : %s\n",(_request==REQUEST_GET) ? "GET":"POST");
		printf("PARAMS : %s\n",_param.c_str());
		
		if (_targetFileName.size() == 0 ) {
			_targetFileName = format("prepare%d",_uid);
		}

		_handle = emscripten_async_wget2(url.c_str(), _targetFileName.c_str(), (_request==REQUEST_GET) ? "GET":"POST", _param.c_str(), this, http::onLoaded, http::onError, http::onProgress);
	
	} else {
		_error = format("malformed url : %s\n",url.c_str());
		_content = "";
		_status = ST_FAILED;
		_progressValue = -1;
	}
}
int ofxEmscriptenURLFileLoader::saveAsync(string url, string path){
	ofHttpRequest * req = new ofHttpRequest(url,url,true);
#if __EMSCRIPTEN_major__>1 || (__EMSCRIPTEN_major__==1 && __EMSCRIPTEN_minor__>22)
	emscripten_async_wget2(url.c_str(), path.c_str(), "GET", "", req, &onload_file_cb, &onerror_file_cb, NULL);
#endif
	return 0;
}
Beispiel #3
0
void FileRequestAsync::Start() {
	if (state == State_Pending) {
		return;
	}

	if (IsReady()) {
		// Fire immediately
		DownloadDone(true);
		return;
	}

	state = State_Pending;

#ifdef EMSCRIPTEN
	std::string request_path = "games/?file=" + path;
	if (!Player::emscripten_game_name.empty()) {
		request_path += "&game=" + Player::emscripten_game_name;
	}

	emscripten_async_wget2(
		request_path.c_str(),
		path.c_str(),
		"GET",
		NULL,
		this,
		download_success,
		download_failure,
		NULL);
#else
	// add comment for fake download testing
	DownloadDone(true);
#endif
}
	void Process()
	{
		UE_LOG(LogMapPakDownloader, Warning, TEXT("Starting Download for %s"), *FileName);

		emscripten_async_wget2(
			TCHAR_TO_ANSI(*(Url + FString(TEXT("?rand=")) + FGuid::NewGuid().ToString())),
			TCHAR_TO_ANSI(*FileName),
			TCHAR_TO_ANSI(TEXT("GET")),
			TCHAR_TO_ANSI(TEXT("")),
			this,
			&FEmscriptenHttpFileRequest::OnLoad,
			&FEmscriptenHttpFileRequest::OnError,
			&FEmscriptenHttpFileRequest::OnProgress
			);
	}