Is it normal for me to send an array to a delegate and receive only a single entry?

I created a custom UObject class called UCML which contains a TArray of another custom UObject class called UCMLData. Right before I broadcast my UCML I do a UE_Log to check the number of UCMLData objects and I get the value 3. When I get to the delegate function and I do the same it returns 1. My classes both contain a ToString() function so I call that and, true to form, there is only 1 entry…

Am I doing something wrong here?

EDIT: Count() is just a getter that returns Elements.Num();

//in the .h file
UDELEGATE(BlueprintCallable)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FWFGHttpResponseDelegate, UCML*, Data);

...

public:
UPROPERTY(BlueprintAssignable, Category = "Response Delegates")
FWFGHttpResponseDelegate OnSuccess;
//in the .cpp file
	UCML* ServerResponse = NewObject<UCML>(UClass::StaticClass());
	ServerResponse->Parse(DecodedHTTPResponse, true);
	UE_LOG(
		LogTemp, Warning, 
		TEXT("Data contins this many nodes %d when calling broadcast"), 
		ServerResponse->Count());
	OnSuccess.Broadcast(ServerResponse);
//in my other file .h:
FScriptDelegate CallFetchACategory;

//in.cpp
	CallFetchACategory.BindUFunction(this, "FetchACategory");
	WUData->OnSuccess.AddUnique(CallFetchACategory);

	void UDemoWordPressDataWidget::FetchACategory(UCML* Response)
	{
		UE_LOG(LogTemp, Warning, 
			TEXT("Parsed Data contins this many nodes %d in linked function"),
			Response->Count());

Never mind. I found the problem.

I was contacting the server 3 times and adding a delegate response only before making the third call, expecting the third server response to trigger that delegate. Due to the delay in contacting the server, though, the second call to the server returned after I set the response delegate and THAT then triggered the incorrect UE_LOG results.

Basically I was calling the server too quickly and not waiting for it to respond before continuing.

Bad move :sweat_smile: My bad…

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.