Technical Details - HeliosOrg/SimpleDataIntegration GitHub Wiki

How does the plugin work?

When you right-click within a Blueprint's Event Graph, a dropdown menu of all the available nodes appears. Unreal Engine looks through all nodes that inherit from K2Node and calls their GetMenuActions function. When this function is called in our K2Node_Helios, we read the input.json file and extract the url as well as the variable information. We then iterate over all the variables and call a lambda function that initializes the nodes.

We pass ServerUrl and HeliosClassType (the variable names in the input.json file) to the newly initialized nodes. The nodes then use this information to decide on their proxy class and proxy factory function. When the flow of execution passes through our nodes in Blueprint, the nodes use this proxy factory function to create a proxy object that does all the real work.

The proxy object (see here for an example) is initialized by the HeliosHelperLibrary and then its SendHeliosRequest is called. The proxy object thus sends a GET or POST request to the designated server and calls OnHeliosRequestComplete when the server responds. For Getter nodes, most of the work is done in OnHeliosRequestComplete function and the received value is broadcasted to the OnSuccess pin (see here for an example). For Setter nodes, most of the work is done in SendHeliosRequestComplete where a POST request is sent with the appropriate data and a simple true is broadcasted to the OnSuccess pin (see here for an example).

Most of the other code in the K2Node_Helios is to make the final Blueprint nodes as clean as possible. In AllocateDefaultPins, we hide pins that the user doesn't need to see.

If we are hiding the pins why are they there in the first place?

There is no clean way to pass information from K2Node_Helios to the proxy objects. We set a proxy class and a proxy factory function but we can't pass any parameters to that function. Thus, our workaround, as suggested by Nick Whiting from Epic Games, is to use the factory function parameters that create pins automatically and then set the default values of these pins in AllocateDefaultPins. We are thus able to pass data to the proxy class from K2Node_Helios. However, we don't want all these ugly pins showing up for the user, so we hide them.

Why is a true broadcasted to the OnSuccess pin for Setter nodes?

In order for the flow of execution to pass through the OnSuccess pin, we need to broadcast a value to it. Thus, we broadcast an arbitrary true that can technically be retrieved from the output pin. However, this value isn't useful to the user, so we hide the pin to avoid confusion.

Isn't reading the input.json file every time you right click inefficient?

The results of the GetMenuActions functions are cached, so we don't read the file every time. This does mean that you should close and re-open UE4 if you change the input.json file so that the available nodes are updated in the dropdown menu.