Playfab login to Lobby

Options
Greetings everyone!
I've followed some youtube tutorials and the docs of playfab and photon so i can create a basic, login -> server select -> lobby (room listing) -> create room or join room but i'm stuck as server select.
After using the code docs and yt provided me 1 I couldn't get the "OnConnectedToMaster" or "OnJoinedLobby" events, I'm using photon cloud, this is the console log error.
with PhotonNetwork.ConnectUsingSettings() i get this when creating room https://imgur.com/a/eHjeGHz
without any connection https://imgur.com/a/mQB0kRP
Why is this happening and what should I do in order to get this right?

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited June 2020
    Options
    Hi @Spaafy,

    Thank you for choosing Photon!

    Call PhotonNetwork.ConnectUsingSettings(); after setting AuthValues.
    check it's return value, it should not be false.
    then wait for callback OnConnectedToMaster or OnDisconnected.
    Override those by extending MonoBehaviourPunCallbacks.
    do not call CreateRoom before OnConnectedToMaster is called.
  • Spaafy
    Spaafy
    edited June 2020
    Options
    JohnTube wrote: »
    Hi @Spaafy,

    Thank you for choosing Photon!

    Call PhotonNetwork.ConnectUsingSettings(); after setting AuthValues.
    check it's return value, it should not be false.
    then wait for callback OnConnectedToMaster or OnDisconnected.
    Override those by extending MonoBehaviourPunCallbacks.
    do not call CreateRoom before OnConnectedToMaster is called.

    Called PhotonNetwork.connectusingsettings from playfab controller
    It returned false.
    Added the overrides, nothing returned cause it didn't connect, only the disconnect said something
    Photo1.. Also I added a check when creating the room (PhotonNetwork.isConnected) if true => return;
    Forgot to mention that I have server select in scene 0, once I press the join server button, it's loging in to photon then changing scene to 1 where I have another script calling the overrides.

    Join server script
    Scene network script

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited June 2020
    Options
    Hi @Spaafy,

    I highly recommend you pause this project and learn more about PUN by finishing the PUN Basics Tutorial first.

    Do not connect Photon client before PlayFab authentication.
    You are already calling ConnectUsingSettings twice in the screenshot snippet.
    do this instead:
    bool result = PhotonNetwork.ConnectUsingSettings();
    Debug.LogFormat("PhotonNetwork.ConnectUsingSettings() returned {0}", result);
    

    Load the scene inside OnConnectedToMaster otherwise callbacks may never be called because of two reasons:
    - callbacks are deregistered in OnDisable which happens when scene unloaded because scripts are removed. Load the scene inside OnConnectedToMaster instead.
    - incoming messages may be processed when the scene is loaded and before new callbacks classes from the new scene are registered in OnEnable. You could try disabling message queue before loading the scene (PhotonNetwork.IsMessageQueueRunning = false;) and enabling it back right after (PhotonNetwork.IsMessageQueueRunning = true;).

    "You have been disconnected from the game server" is a misleading log message as Photon has 3 types of servers: NameServer, MasterServer and GameServer and you are not checking the type of the server. So just log "You have been disconnected from Photon servers".
  • Spaafy
    Options
    Thank you, I took my time reading the docs and I can tell that I made big mistakes, sorry for asking without looking at the instructions, no problem anymore everything works.