Able to join Lobby but not creating room?

Options
Hi, I have just started learning integrating Photon into my game but I have run into a weird problem. My debug log shows that I have connected to Photon and joined the Lobby. But when the code tries to create a room, OnCreatedRoom function is never called nor did I ever get a failed response from the Photon Server. Does anyone have any idea what is this about?

I am using Photon Classic on Unity 2018.3.6f1 Personal.

Here is the error.

Before anyone ask, the first 2 NullReferenceException has nothing to do with Photon.

CreateRoom.cs

using TMPro; using UnityEngine; public class CreateRoom : MonoBehaviour { [SerializeField] private TMP_InputField _roomName; private TMP_InputField RoomName { get { return _roomName; } } public void OnClick_CreateRoom() { RoomOptions roomOptions = new RoomOptions() { IsVisible = true, IsOpen = true, MaxPlayers = 4 }; if (PhotonNetwork.CreateRoom(RoomName.text, roomOptions, TypedLobby.Default)) { Debug.Log("Successfully sent create room message: " + RoomName.text); //PhotonNetwork.JoinRoom(RoomName.text); //PhotonNetwork.JoinOrCreateRoom(RoomName.text, roomOptions, TypedLobby.Default); } else { Debug.Log("Failed sending create room message."); } } private void OnPhotonCreateRoomFailed(object[] codeAndMessage) { Debug.Log("Failed creating room: " + codeAndMessage[1]); } private void OnCreatedRoom() { Debug.Log("Room created successfully"); } }
LobbyNetwork.cs

using UnityEngine; public class LobbyNetwork : MonoBehaviour { void Start() { Debug.Log("Connecting to server"); PhotonNetwork.ConnectUsingSettings("1.0"); } public void OnConnectedToPhoton() { Debug.Log("Connected to Photon."); } private void OnConnectedToMaster() { Debug.Log("Connected to master"); PhotonNetwork.playerName = PlayerNetwork.Instance.PlayerName; PhotonNetwork.JoinLobby(TypedLobby.Default); } private void OnJoinedLobby() { Debug.Log("Joined Lobby"); } }

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited March 2019
    Options
    Hi @ginhikari,

    Thank you for choosing Photon!

    The code does not match console logs.

    Create operation has code 227.
    Join operation has code 226.

    The errors you see are for Join or JoinOrCreate method calls.
    you must have that somewhere in your code and it's called twice after you join the lobby and once on the game server (which is weird and should not happen by default).
    My guess is that they are due to the commented lines:
    //PhotonNetwork.JoinRoom(RoomName.text);
                //PhotonNetwork.JoinOrCreateRoom(RoomName.text, roomOptions, TypedLobby.Default);