question

cihan-gs avatar image
cihan-gs asked

After created lobbyy change SearchProperties?

Hello, I want to change the SearchProperties of a lobby created via PlayFab in Unity. However, I couldn't find how to do it, can you help me? When creating a lobby, I create SearchProperties like this, how can I update them after the lobby is created? I would appreciate it if you could provide an example with code.

SearchProperties = new Dictionary() { {PlayFabManager.Instance.PlayFabSearchOwnerSteamID, PlayFabManager.Instance.Id }, {PlayFabManager.Instance.PlayFabSearchKeyLobbyName, PlayFabManager.Instance.Username+"'s lobby" }, {PlayFabManager.Instance.PlayFabSearchKeyLobbyCurrentPlayerCount, 1.ToString()} }

multiplayer
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Xiao Zha avatar image
Xiao Zha answered

You may refer to the code below to update the lobby search properties.

  //The authenticationcontext of the player who is currently logged in, you can set it in the login result
    
 PlayFabAuthenticationContext localuser;
        
     //The lobby entity that the player created or joined, you can set it like this: LobbyEntity = PlayFabMultiplayer.CreateAndJoinLobby(...)...
    
 public Lobby LobbyEntity;
        
     public void UpdateLobby()
     {
         PlayFabMultiplayer.OnLobbyPostUpdateCompleted += PlayFabMultiplayer_OnLobbyUpdateCompleted;
        
         PlayFabMultiplayer.OnLobbyUpdated += PlayFabMultiplayer_OnLobbyUpdated;
        
         LobbyDataUpdate LobbyData = new LobbyDataUpdate();
        
         var SearchProperties = new Dictionary<string, string>();
        
         SearchProperties["string_key2"] = "TestLobbyName3";
        
         LobbyData.SearchProperties=SearchProperties;
        
         LobbyEntity.PostUpdate(localuser, LobbyData);
     }
        
     private void PlayFabMultiplayer_OnLobbyUpdated(Lobby lobby, bool ownerUpdated, bool maxMembersUpdated, bool accessPolicyUpdated, bool membershipLockUpdated, IList<string> updatedSearchPropertyKeys, IList<string> updatedLobbyPropertyKeys, IList<LobbyMemberUpdateSummary> memberUpdates)
     {
         Debug.Log("Update Lobby Successed");
        
         foreach (var key in updatedSearchPropertyKeys) { Debug.Log(key); };
     }
        
     private void PlayFabMultiplayer_OnLobbyUpdateCompleted(Lobby lobby, PFEntityKey localuser, int reason)
     {
         if (LobbyError.SUCCEEDED(reason))
         {
             Debug.Log("UpdateLobbyCallSuccessed");
         }
         else
         {
             Debug.Log("UpdateLobbyCallFailed");
         }
     }
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

cihan-gs avatar image cihan-gs commented ·

Thank you very much

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.