Photon multiplayer room make disappear in lobby when room is getting full

Hi all,
I am making realtime multiplayer game and using photon realtime networking SDK.
want to Provide on options like for matchmaking rooms.

  1. Room#1 - with two maximum player capacity
    2)Room#2 - with four maximum player capacity

If in these case if Room#1 player count (getting full) then this room name should not be visible in lobby.
same as for 4 player Room#2, it should getting visible false. these room should not visible to other connected player in lobby.
How can it is possible ?
which photon function should i have call ? and when call ?

Thanks in advance

To hide a room from the lobby : = false;

To close a room : = false;

Typically you could handle toggling these values in the callbacks OnJoinedRoom() and OnPhotonPlayerConnected( PhotonPlayer other )

e.g. the master client keeps track of when someone joins the room. If the maximum number of players is in the room, then set visible and open to false. You really only need to use visible, however open is useful if the person knows the room name (even if it is not listed in the lobby).

OnPhotonPlayerConnected( PhotonPlayer other ) is not seen by the person joining the room, only all others in the room. So the master client would use OnJoinRoom. Example untested code :

int maxNumPlayers = 2; // 2,4, whatever value you set in CreateRoom()
int playerCount = 0;

void OnJoinedRoom()
	// master client joined, set playerCount to 1
	if ( PhotonNetwork.isMasterClient ) 
		playerCount = 1;

void OnPhotonPlayerConnected( PhotonPlayer other ) // not seen if you're the player connecting
	// player joined, master client then increments playerCount
	if ( PhotonNetwork.isMasterClient ) 
		playerCount ++;
		// hide and close the room if it is full
		if ( playerCount == maxNumPlayers )
		{ = false; = false;