Creating Rooms With Random Gives me an Error

i cant understand what kind of error message is that mean .. & and whats wrong with my Code .
Any Help Please ?

My Code :
using Photon.Pun;
using Photon.Realtime;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Chating : MonoBehaviourPunCallbacks 
{
    int y=10;
    public InputField Input_Player_Name;
    public InputField Input_ActorNumber;
    string player_Name;
    int actorNumber;
    Player player;
    RoomOptions rm;
    string RoomName="Test";
      
    public void OnkButtonClicked ()
    {
        PhotonNetwork.ConnectUsingSettings();
        player_Name = Input_Player_Name.text;
        actorNumber = int.Parse(Input_ActorNumber.text);
        player = new Player(player_Name, actorNumber, true);
        player.UserId = actorNumber.ToString() ;
        
               
       
    }
    void OnGUI()
    {
        GUI.Label(new Rect(0, 10, 400, 500+y), PhotonNetwork.NetworkClientState.ToString());
        y += 5;
    }
    
    public override void OnConnectedToMaster ()
    {
        Debug.Log("Connected To : " + PhotonNetwork.NetworkClientState.ToString());
        PhotonNetwork.JoinLobby(TypedLobby.Default);
    }
    public override void OnJoinedLobby()
    {
            Debug.Log("Was Joined To Lobby .....and he is Master Client");
            rm = new RoomOptions() { IsVisible = true, IsOpen = true, MaxPlayers = 2 };
              for (int num = 0; num < 10; num++)
               {
                 RoomName = "Test" + Random.Range(1, 1000);
                 PhotonNetwork.JoinOrCreateRoom(RoomName , rm, TypedLobby.Default, null);
               }
    }
    public override void OnCreatedRoom()
    {
        Debug.Log("Room Was Created .....");
        PhotonNetwork.JoinRoom(RoomName,null);        
    }
    public override void OnJoinRoomFailed(short ss, string st)
    {
        Debug.Log("Room Was Not Joined .....");
        PhotonNetwork.JoinRoom(RoomName);
    }
    public override void OnJoinedRoom ()
    {
        Debug.Log("Room Was Joined ......");
    }
    
}
Error Massage Was like That :
JoinRoom failed. Client is on GameServer (must be Master Server for matchmaking) and ready. Wait for callback: OnJoinedLobby or OnConnectedToMaster.

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @Tamim_Zoabi,

    for (int num = 0; num < 10; num++)

    Why do you need to call JoinOrCreateRoom 10 times?
    If the use case is to create rooms inside the lobby then this is not the way to do it from Photon.
    Just create one room per client or create a room then leave it to create another one.

    Empty rooms will be removed from Photon servers after EmptyRoomTTL.