I want to create new room if players reached to maximum number limit.
I have checked Service room but its not creating new room when 3 rd player tries to join same room.
I am limiting player by using below code :
- Code: Select all
public override bool AllowUserJoin(Player player)
{
int maxplayers = 2; //Default
//Check if there's room for this player.
if (Players.Count() < maxplayers)
{
return true;
}
return false;
}
and connection i have made something like this :
- Code: Select all
client.Multiplayer.CreateJoinRoom(
"$service-room$", //Room id. If set to null a random roomid is used
"UnityPoker", //The room type started on the server
true, //Should the room be visible in the lobby?
null,
null,
delegate(Connection connection) {
Debug.Log("Joined Room.");
// We successfully joined a room so set up the message handler
pioconnection = connection;
pioconnection.OnMessage += handlemessage;
joinedroom = true;
},
delegate(PlayerIOError error) {
Debug.Log("Error Joining Room: " + error.ToString());
}
);
What sholu i do to make this work ?
any other way is there ?
Thanks.