Search Unity

Matchmaking: Room gets destroyed after a few seconds

Discussion in 'Scripting' started by Elisabeth123, Jul 31, 2019.

  1. Elisabeth123

    Elisabeth123

    Joined:
    Feb 17, 2016
    Posts:
    13
    Hi, I have the following problem: I am using the Matchmaking Service and I can open a new room and also connect to it, but for some reason the room gets closed after a few seconds even if noone is connected except the host. I am using this code:

    Code (CSharp):
    1.  public void CreateRoom()
    2.     {
    3.         if(roomName != "" && roomName != null)
    4.         {
    5.             Debug.Log("Cerating Room: " + roomName + " with room for " + roomSize + " players");
    6.             //Create Room
    7.             //networkManager.matchMaker.CreateMatch(roomName, roomSize, true, "", "", "", 0, 0, networkManager.OnMatchCreate);
    8.             networkManager.matchMaker.CreateMatch(roomName, roomSize, true, "", "", "", 0, 0, OnMatchCreate);
    9.         }
    10.     }
    11.  
    12.     public void OnMatchCreate(bool success, string extendedInfo, MatchInfo matchInfo)
    13.     {
    14.         if (LogFilter.logDebug) { Debug.LogFormat("NetworkManager OnMatchCreate Success:{0}, ExtendedInfo:{1}, matchInfo:{2}", success, extendedInfo, matchInfo); }
    15.  
    16.         if (success)
    17.             networkManager.StartHost(matchInfo); //Todo: Varify other hooks
    18.     }
    Can someone tell me what I am doing wrong?

    Thanks!

    BR, Elisabeth
     
  2. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    Have your get success == true in OnMatchCreate callback? How did you knew the room was closed?
     
  3. Elisabeth123

    Elisabeth123

    Joined:
    Feb 17, 2016
    Posts:
    13
    Hi, yes I got success. Because I have a button to refresh the room list, and after a few second the room is not in this list any more.
     
  4. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    I think you should start host after enogh players joined the room, not right after it's created.
     
  5. Elisabeth123

    Elisabeth123

    Joined:
    Feb 17, 2016
    Posts:
    13
    I thought the host opens a new room?
     
  6. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    No. New host starts game host for players in room.