I’ll align the info about my prject and code first:
I wanna download a file from URL address, then open/read it.
I am created a C++ class inherit from UBlueprintFunctionLibrary with a BlueprintCallable static function(void UDownloadURLFile::DownloadURLFile).
Then, I add another C++ class inherit from UObject named UFileDownloadWorker, in the function UDownloadURLFile::DownloadURLFile, a local UFileDownloadWorker object will do the really download job.
There’s two function in worker:
bool Download(FString URL, FString LocalFile);
void HttpCompleteCallBack(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bSuccess);
HttpCompleteCallBack is bind in http request by using:
Till now, the funtions works well, and after posting http request, callback function can also bring the datas back.
My question is :
After I call the BlueprintCallable function in UBlueprintFunctionLibrary, it returns immediately after post the http request.
It seems that, callback function HttpCompleteCallBack will runs in background.
Now I’m confused, How can I let the blueprint wait for the callback function finished and do the following logic?
(Just like the windows API : WaitForSingleObject)
I’ve tried to send the event by using BlueprintImplementableEvent, but I don’t know how to use it right.
Here’s my way:
Firstly, I’ve created a C++ class named UDownloadingNotice with BlueprintImplementableEvent function.
Then I add a blueprint class inherit from it.
At last, I overwrite BlueprintImplementableEvent function in blueprint.
I call the BlueprintImplementableEvent function in C++ code, but it didn’t work.
I guess that the UDownloadingNotice object created in C++ code is not exist in blueprint. but I also don’t know how to link them.
In another word, I don’t know how to use BlueprintImplementableEvent function ( how to invoke it , which class to put it in).
I will be very grateful for any comments and suggestions.
Thanks very much.