Hi Epicfolk,
I’m working on an OSS Steam integration in UE4.27, and I’m hitting a snag:
I set up the online subsystem using the info here, and it seemed to be going smoothly. I’m able to create a session, search for it, and join the session using another Steam account on a different PC.
Once two players are in the session, I have a problem: session->RegisteredPlayers isn’t being updated. My understanding is that this array should contain a list of the SteamIds for all players in the session, but session->RegisteredPlayers.Num() returns 0, and I don’t see any other way to get the SteamIds of players in the session.
Also, I’ve set up delegates for these callbacks, but neither of the delegates fires for the session host when another player joins the session:
- OnSessionParticipantsChange
- OnRegisterPlayersComplete
Other pieces of information about the session like session->OwningUserId and session->GetSessionIdStr() return the correct value for all players, so I think the players have joined the session successfully. But I haven’t found a way to exchange the SteamIds!
Why I need the SteamIds: I’m trying to set up a P2P connection using SteamSockets, which requires the SteamIds for NAT punchthrough and starting the connection.
Any ideas I can try?
Abridged code snippets, in case they’re relevant:
void UMultiplayerSessionsSubsystem::CreateSession(int32 NumPublicConnections, FString SessionName)
{
//Create a new session settings object
TSharedPtr<FOnlineSessionSettings> SessionSettings = MakeShareable(new FOnlineSessionSettings());
//Standard settings (creating as a lobby, with presence)
SessionSettings->bIsDedicated = false;
SessionSettings->NumPublicConnections = NumPublicConnections;
SessionSettings->bAllowJoinInProgress = true;
SessionSettings->bAllowJoinViaPresence = true;
SessionSettings->bIsLANMatch = false;
SessionSettings->bShouldAdvertise = true;
SessionSettings->bUsesPresence = true;
SessionSettings->Set(FName("SessionName"), SessionName, EOnlineDataAdvertisementType::ViaOnlineServiceAndPing);
SessionSettings->bUseLobbiesIfAvailable = true;
//Create the session
SessionInterface->CreateSession(*NetId, NAME_GameSession, *LastSessionSettings);
}
//... Functions for searching for sessions and joining a session ...
//Print some info for testing
void UMultiplayerSessionSubsystem::PrintSessionData()
{
//Get the named session object (the session name is stored when joining, for lookup)
FNamedOnlineSession* session = SessionInterface->GetNamedSession(CurrentSessionName);
//Print info. This correctly prints GetSessionIdStr(), but shows 0 for RegisteredPlayers.Num()
GEngine->AddOnScreenDebugMessage(
-1,
15.f,
FColor::Green,
FString::Printf(TEXT("UMultiplayerSessionMenu::Tick --- net ids in session %s: %d), *session->GetSessionIdStr(), session->RegisteredPlayers.Num())
);
}