[UNet] How to prevent players from joining a game in progress

In the documentation we can read that UNet provide an “Option to prevent players from joining a game in progress” (here http://docs.unity3d.com/Manual/class-NetworkLobbyManager.html).

Can someone tell how to do it? I tried to find something in the documentation and also manipulate some of NetworkLobbyManager and NetworkServer properties, but I wasn’t able to receive expected results. I checked “Network Game Lobby” project sample from asset store and I observed that this problem exists there too.

Steps to reproduce:

  1. Build “Network Game Lobby” project sample,
  2. Open two instances of the game,
  3. Create room on the first instance,
  4. Join to the room on the second instance,
  5. Press “Ready” button on the both instances,
  6. Left from the game on the second instance,
  7. Wait a few seconds or open third instance of game,
  8. Check list of available rooms.

You will be able to see our room in this list, although the game is still in progress.

Cheers,
Dominik

Hi @DominikP
I had the same problem.
I solved it using Unity 5.4, in which they introduced the SetMatchAttribute method in the NetworkMatch class (https://docs.unity3d.com/ScriptReference/Networking.Match.NetworkMatch.SetMatchAttributes.html).
I call it from the server when the game start, setting the “isListed” flag to false.
This prevents the match is visible in the NetworkMatch.ListMatches results .
Hope this will help you
Cheers,
Alessio