I’m getting a problem with clearing delegates from Session Interface.
Every time that a UserWidget called “HostGame_UserWidget” is added to viewport it should clear all binds for “OnCreateSessionCompleteDelegate” and bind a new UObject. I know how to bind the UObject (A function called “OnCreateSessionComplete”), but I really don’t know how to clear the existing binds.
Here is my code that do that stuff:
void UHostGame_UserWidget::NativeConstruct()
{
UMultiplayer_GameInstance* GameInstanceRef = Cast<UMultiplayer_GameInstance>(GetGameInstance()); Super::NativeConstruct();
if (GameInstanceRef->SessionInterface.IsValid())
{
// I need to clear OnCreateSessionCompleteDelegate here, but I don't know how this function works.
GameInstanceRef->SessionInterface->ClearOnCreateSessionCompleteDelegates();
// Here I Bind the "OnCreateSessionComplete". There's no problem here.
GameInstanceRef->SessionInterface->OnCreateSessionCompleteDelegates.AddUObject(this, &UHostGame_UserWidget::OnCreateSessionComplete);
}
}
void UHostGame_UserWidget::OnCreateSessionComplete(FName ServerName, bool Success)
{
//Some code here...
}
Is the function “ClearOnCreateSessionCompleteDelegates()” used for clear binds?