Having trouble binding delegates of the online-sessions interface to own functions

Hello dear community,

for 2 days now, I am having trouble to bind a function to delegates from the OnlineSession interface.
For example, there is this nice delegate called FOnSessionInviteReceivedDelegate, which I want to bind a function to. So, I did the following:

First, I created a delegate variable within my .h file:

const FOnSessionInviteReceivedDelegate onSessionInviteRecievedDelegate;

Second, I declared a function, which is supposed to bind to the delegate:

void OnInviteRecieved(const FUniqueNetId & bWasSuccessful, const FUniqueNetId & ControllerId, const FString & UserId, const FOnlineSessionSearchResult & InviteResult);

Later, in my .cpp file, I am using these lines:

`
IOnlineSubsystem* OnlineSubsystem = IOnlineSubsystem::Get(“Steam”);

IOnlineSessionPtr Sessions = OnlineSubsystem->GetSessionInterface();
Sessions->AddOnSessionInviteReceivedDelegate_Handle(onSessionInviteRecievedDelegate);
onSessionInviteRecievedDelegate.BindSP(this, &UTheCompanyGameInstance::OnInviteRecieved);
`

That’s when I keep getting the error-message that the function’s signature does not comply with the signature of the delegate. When I dig into the OnlineSessionInterface.h file to lookup the delegate, I find the following:

`

DECLARE_MULTICAST_DELEGATE_FourParams(FOnSessionInviteReceived, const FUniqueNetId& /UserId/, const FUniqueNetId& /FromId/, const FString& /AppId/, const FOnlineSessionSearchResult& /InviteResult/);
typedef FOnSessionInviteReceived::FDelegate FOnSessionInviteReceivedDelegate;`

Which indicates me that my function’s signature is correct, isn’t it?

Can somebody tell me what on earth I am doing wrong?
Any help would be much appreciated :-).

Best wishes,

You’ll likely want to use BindUObject instead of BindSP for your UObject. SP stands for Shared Pointers, and will only work on TSharedPtrs/TSharedRefs.

Hello Maide thank you for your response. Your advice wasn’t exaclty the solution to my current problem, which I just solved, but I am sure that would have been the next issue on the list. I actually solved my issue by NOT declaring the delegates as const (just saying for anyone that runs into the same issue). Thanks a lot for your help. +1