Hey I’m working on a multiplayer game and I thought it would be good if when the host starts the game (with all the players already in the session) that no other people can join after. Basically the server is private only for the people in the server now so no one joins mid game. Anyone know how to set this up?
We’re u able to find out a solution ?
hey there, anyone an idea ? I´m struggling on the same issue…
Is this not solvable through the FOnlineSessionSettings?
I’d imagine that simply turning the boolean bShouldAdvertise to false once the session has started would make the session invisible to session browsers.
Alternatively with the bAllowJoinInProgress you should be able to limit joinability to once the session has started, without having to do any session modifications. However this functionality might differ depending on platform implementation.
From class FOnlineSessionSettings
/** The number of publicly available connections advertised */
int32 NumPublicConnections;
/** The number of connections that are private (invite/password) only */
int32 NumPrivateConnections;
/** Whether this match is publicly advertised on the online service */
bool bShouldAdvertise;
/** Whether joining in progress is allowed or not */
bool bAllowJoinInProgress;
/** This game will be lan only and not be visible to external players */
bool bIsLANMatch;
/** Whether the server is dedicated or player hosted */
bool bIsDedicated;
/** Whether the match should gather stats or not */
bool bUsesStats;
/** Whether the match allows invitations for this session or not */
bool bAllowInvites;
/** Whether to display user presence information or not */
bool bUsesPresence;
/** Whether joining via player presence is allowed or not */
bool bAllowJoinViaPresence;
/** Whether joining via player presence is allowed for friends only or not */
bool bAllowJoinViaPresenceFriendsOnly;
/** Whether the server employs anti-cheat (punkbuster, vac, etc) */
bool bAntiCheatProtected;
/** Whether to prefer lobbies APIs if the platform supports them */
bool bUseLobbiesIfAvailable;
/** Whether to create (and auto join) a voice chat room for the lobby, if the platform supports it */
bool bUseLobbiesVoiceChatIfAvailable;
/** Manual override for the Session Id instead of having one assigned by the backend. Its size may be restricted depending on the platform */
FString SessionIdOverride;
/** Used to keep different builds from seeing each other during searches */
int32 BuildUniqueId;
/** Array of custom session settings */
FSessionSettings Settings;
/** Map of custom settings per session member (Not currently used by every OSS) */
TUniqueNetIdMap<FSessionSettings> MemberSettings;
From class FNamedOnlineSession
/**
* Calculate the possible joinability state of this session
* check the values from left to right in order of precedence
*
* @param bPublicJoinable [out] is the game joinable by anyone at all
* @param bFriendJoinable [out] is the game joinable by friends via presence (doesnt require invite)
* @param bInviteOnly [out] is the game joinable via explicit invites
* @param bAllowInvites [out] are invites possible (use with bInviteOnly to determine if invites are available right now)
*
* @return true if the out params are valid, false otherwise
*/
bool GetJoinability(bool& bPublicJoinable, bool& bFriendJoinable, bool& bInviteOnly, bool& bAllowInvites) const
{
// Only states that have a valid session are considered
if (SessionState != EOnlineSessionState::NoSession && SessionState != EOnlineSessionState::Creating && SessionState != EOnlineSessionState::Destroying)
{
bool bAllowJIP = SessionSettings.bAllowJoinInProgress || (SessionState != EOnlineSessionState::Starting && SessionState != EOnlineSessionState::InProgress);
if (bAllowJIP)
{
bPublicJoinable = SessionSettings.bShouldAdvertise || SessionSettings.bAllowJoinViaPresence;
bFriendJoinable = SessionSettings.bAllowJoinViaPresenceFriendsOnly;
bInviteOnly = !bPublicJoinable && !bFriendJoinable && SessionSettings.bAllowInvites;
bAllowInvites = SessionSettings.bAllowInvites;
}
else
{
bPublicJoinable = false;
bFriendJoinable = false;
bInviteOnly = false;
bAllowInvites = false;
}
// Valid session, joinable or otherwise
return true;
}
// Invalid session
return false;
}