Well, Hi guys hope everyone is doing good. The problem I am facing is that my functions are executing together. There is a function A that has a URL and it calls that URL now it sends that URL to function B. Now the job of function B is to return a token from that URL back to function A but what’s happening is that function A and Function B run at the same time without waiting for each other and due to this I can’t get the data in blueprints. and only function A is exposed to the unreal blueprints.
Isn’t the real problem that making a web request will take some time, and you actually need the entire game to keep going while the asynchronous fetch is running?
In general, an asynchronous task like that will have either an event dispatcher (which you can build in blueprint,) or a separate output execution pin (which can only be made in C++, and only used in event dispatchers, not in functions.)
So, split A into two, call it “A_First” and “A_Last.” Have A_First bind A_Last to some event dispatcher that function B will call once it has the result.
Jwatte thx for the replay, Well Function A is being run to call a wallet so these functions are taking place in the looby so waiting is not a problem. But the issue is how can I split the function In two and If I could then I would have to do the same for the other 15 functions. As this same behavior is being observed in the other functions with different functionalities.
Yes, this is what you have to do in an asynchronous runtime. Each request/response needs some kind of “split” or “callback” or “completion event” mechanism.
Node.js is very similar, btw, as is any web page code. You can’t block waiting on a network request when there’s an interactive application running at the same time.
In short: Yes, an asynchronous API requires that you split “make request” from “handle response,” and deal with the uncomfortable state in the middle of “having sent a request but not having a response.” It’s one of the challenges of networked user intefaces.
For functions that are specifically for calling in an Event Dispatcher, you can actually create coroutines, that have two execution output pins – one for “continue before having gotten the data,” and one for “now I have the data; you can use it.” It’s slightly more convenient to use (for blueprinters) than the event dispatcher, but requires special C++ support for each of those functions.