I’ve tried a million different ways and nothing works for me, I really don’t know what I’m doing wrong but I’m getting all manner of errors, like these:
error: no matching member function for call to '__Internal_AddDynamic'
and
candidate function [with UserClass = FPlayFabRequestAction] not viable: no known conversion from 'void (FPlayFabRequestAction::*)(UVaRestJsonObject *)' to 'typename FDelegate::TMethodPtrResolver<FPlayFabRequestAction>::FMethodPtr' (aka 'void (FPlayFabRequestAction::*)(UVaRestRequestJSON *)') for 2nd argument
Here is the class I’m trying to bind from, It’s a latent action, I’m trying to make a wrapper around va_rest so I can do some extra operations depending on the result of a request. Here’s the relevant code:
class FPlayFabRequestAction : public FPendingLatentAction
{
public:
UVaRestRequestJSON* JSON;
FString Url;
FString Ticket;
EPlayFabRequestResult& Exec;
FName ExecutionFunction;
int32 OutputLink;
FWeakObjectPtr CallbackTarget;
FPlayFabRequestAction(UVaRestRequestJSON* Data, FString Endpoint, FString ticket, EPlayFabRequestResult& Branches, const FLatentActionInfo& LatentInfo) :
JSON(Data),
Url(Endpoint),
Ticket(ticket),
Exec(Branches),
ExecutionFunction(LatentInfo.ExecutionFunction),
OutputLink(LatentInfo.Linkage),
CallbackTarget(LatentInfo.CallbackTarget)
{
UE_LOG(LogTemp, Error, TEXT("Latent contructor was called!"));
JSON->OnRequestComplete.AddDynamic(this, &FPlayFabRequestAction::OnRequestComplete);
}
virtual void UpdateOperation(FLatentResponse& Response) override
{
Exec = EPlayFabRequestResult::Success;
Response.FinishAndTriggerIf(true, ExecutionFunction, OutputLink, CallbackTarget);
}
void OnRequestComplete(UVaRestJsonObject* Result) {
UE_LOG(LogTemp, Error, TEXT("Response Complete"));
}
};
I just can’t get my head around what that error means. What am I doing wrong, I’m pulling my hair out trying to get this working and I’m on a deadline that’s approaching fast. Please, please advise me anybody.
EDIT
As thesilencelies rightly pointed out, I was using the wrong type. The callback function should be defined like so
void OnRequestComplete(UVaRestRequestJSON * Result)
But this generates other errors:
CompilerResultsLog: Info /Users/Shared/UnrealEngine/4.13/Engine/Source/Runtime/Core/Public/Delegates/DelegateSignatureImpl.inl:1037:16: error: no viable overloaded '='
CompilerResultsLog: Info this->Object = InUserObject;
CompilerResultsLog: Info ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
CompilerResultsLog: Info /Users/Shared/UnrealEngine/4.13/Engine/Source/Runtime/Core/Public/Delegates/DelegateSignatureImpl.inl:1122:15: note: in instantiation of function template specialization 'TBaseDynamicDelegate<FWeakObjectPtr, void, UVaRestRequestJSON *>::__Internal_BindDynamic<FPlayFabRequestAction>' requested here
CompilerResultsLog: Info NewDelegate.__Internal_BindDynamic( InUserObject, InMethodPtr, InFunctionName );
CompilerResultsLog: Info ^
CompilerResultsLog: Info ../../../../../johnbowring/Documents/Dev/Switchum4/Source/Switchum/PlayFabRequestLibrary.h:75:27: note: in instantiation of function template specialization 'TBaseDynamicMulticastDelegate<FWeakObjectPtr, void, UVaRestRequestJSON *>::__Internal_AddDynamic<FPlayFabRequestAction>' requested here
CompilerResultsLog: Info JSON->OnRequestComplete.AddDynamic(this, &FPlayFabRequestAction::OnRequestComplete);
CompilerResultsLog: Info ^
CompilerResultsLog: Info Runtime/Core/Public/Delegates/Delegate.h:382:44: note: expanded from macro 'AddDynamic'
CompilerResultsLog: Info #define AddDynamic( UserObject, FuncName ) __Internal_AddDynamic( UserObject, FuncName, STATIC_FUNCTION_FNAME( TEXT( #FuncName ) ) )
CompilerResultsLog: Info ^
CompilerResultsLog: Info /Users/Shared/UnrealEngine/4.13/Engine/Source/Runtime/CoreUObject/Public/UObject/WeakObjectPtr.h:61:23: note: candidate function not viable: no known conversion from 'FPlayFabRequestAction *' to 'const class UObject *' for 1st argument
CompilerResultsLog: Info COREUOBJECT_API void operator=(const class UObject *Object);
CompilerResultsLog: Info ^
CompilerResultsLog: Info /Users/Shared/UnrealEngine/4.13/Engine/Source/Runtime/CoreUObject/Public/UObject/WeakObjectPtr.h:67:19: note: candidate function not viable: no known conversion from 'FPlayFabRequestAction *' to 'const FWeakObjectPtr' for 1st argument
CompilerResultsLog: Info FORCEINLINE void operator=(const FWeakObjectPtr &Other)
CompilerResultsLog: Info ^
CompilerResultsLog: Info 1 error generated.
I’m really struggling to understand what this all means, any help is so appreciated I can’t express it.