Hello, I couldn't find online any information about the implementation of matchmaking using OnlineSubsystemPlayfab, I promise to open-source my code if you can help me out so that others can have a smoother experience in the future. I do know how to do it with findsession and joinsession, but as far as I understand it won't open the dedicated server, and the way to do it using the cloud system is with startmatchmaking
This is what I currently did
#include "MatchmakingManager.h"
#include "OnlineSubsystemPlayFab.h"
#include "Interfaces/OnlineSessionInterface.h"
#include "OnlineSessionSettings.h"
void AMatchmakingManager::BeginPlay()
{
IOnlineSubsystem* OnlineSubsystem = IOnlineSubsystem::Get();
IOnlineSessionPtr session = OnlineSubsystem->GetSessionInterface();
IOnlineIdentityPtr IdentityInterface = OnlineSubsystem->GetIdentityInterface();
FOnlineSessionSettings SessionSettings;
SessionSettings.bAllowInvites = true;
SessionSettings.bAllowJoinInProgress = true;
SessionSettings.bAllowJoinViaPresence = true;
SessionSettings.bAllowJoinViaPresenceFriendsOnly = false;
SessionSettings.bAntiCheatProtected = false;
SessionSettings.bIsDedicated = true;
SessionSettings.bIsLANMatch = false;
SessionSettings.bShouldAdvertise = true;
SessionSettings.bUseLobbiesIfAvailable = true;
SessionSettings.bUseLobbiesVoiceChatIfAvailable = true;
SessionSettings.bUsesPresence = true;
SessionSettings.bUsesStats = true;
TSharedRef<FOnlineSessionSearch> SessionSearch = MakeShareable(new FOnlineSessionSearch());
SessionSearch.Get().bIsLanQuery = false;
SessionSearch.Get().MaxSearchResults = 1;
FOnStartMatchmakingComplete StartMatchmakingCompleteDelegate;
StartMatchmakingCompleteDelegate.BindUObject(this, &AMatchmakingManager::OnStartMatchmakingComplete);
TArray<FSessionMatchmakingUser> LocalPlayers;
FSessionMatchmakingUser MatchmakingUser;
MatchmakingUser.UserId = IdentityInterface->GetUniquePlayerId(0).ToSharedRef();
LocalPlayers.Add(MatchmakingUser);
session->StartMatchmaking(LocalPlayers, FName("Playtest"), SessionSettings, SessionSearch, StartMatchmakingCompleteDelegate);
}
Here's the function that it will call once complete:
void AMatchmakingManager::OnStartMatchmakingComplete(FName SessionName, const FOnlineError& ErrorDetails, const FSessionMatchmakingResults& Results)
{
// on matchmaking complete logic
}
I noticed that FSessionMatchmakingResults is a "Stub struct that can be easily added to without requiring delegate signature changes". Am I expected to populate it with properties so that I can get information from the results? How do I even make sure that playfab is using the right build?
Would love to hear how to continue from there.
By the way, I did create a working matchmaking with the default Playfab package, but it does not support voice-chat by default as OnlineSubsystemPlayfab does