"OnConnectedToPhoton" and "OnConnectedToMaster" not getting called

Options
Hi there,

I have a question that I need help with. I'd like to first know if first I have the correct approach and secondly if I do, what am I doing wrong? In my game, at the start the user first connects to a database to collect his account information. Once that happens, I do a few things:

PhotonNetwork.autoJoinLobby = false;
PhotonNetwork.automaticallySyncScene = true;
PhotonNetwork.offlineMode = true;
PhotonNetwork.CreateRoom("MainMenu");

While the user is in the Main Menu, he doesn't need to connect to Photon but I do need some of the Photon functionality like the use of RPCs. From the Main Menu, the user can click on "Find Match" where he gets paired up with a single opponent. Players have a personal rating and when they search for a match, they do 8 searches in a row looking for an opponent with the closest rating to theirs. So if they're at 1500 rating, they'll look for someone between 1450 and 1550, if nobody is available then 1400 and 1600 and so on for a total of 8 iterations. If nothing is found, they create their own room and place their own rating in the room options so other people looking for matches can get paired with them.

So when the player presses the "Find Match" button, I do the following:
PhotonNetwork.ConnectUsingSettings(); // with the game version inside ()
I immediately get a notification of "ConnectUsingSettings() disabled the offline mode. No longer offline."
I also get "Best region found in PlayerPrefs. Connecting to: eu"
And "OnConnectedToPhoton" and "OnConnectedToMaster" get called.
The "OnConnectedToMaster" callback checks if we're looking for a match and if we are, it does the custom search for an opponent described above and if it can't find anyone it creates a room.

So far, so good, everything seems to work perfectly. Now I also have a "Cancel Search" button. When pressed I do the following:

PhotonNetwork.Disconnect();
PhotonNetwork.offlineMode = true;
PhotonNetwork.LeaveRoom();
PhotonNetwork.CreateRoom("MainMenu");

If I press the "Cancel Search" button and then I press the "Find Match" button again, I only get as far as "Best region found in PlayerPrefs. Connecting to: eu". "OnConnectedToPhoton" and "OnConnectedToMaster" no longer get called. What am I doing wrong and is this a proper way of doing things?

Thank you!

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @stefanplc,

    Could you check if this is related to the offline mode switching bug reported here (with fix)?
  • stefanplc
    Options
    Thanks for getting back to me! I'm away until Thursday but as soon as I get back I'll make sure to try it out!
  • stefanplc
    Options
    Sorry for the delayed response, got caught with some other work. I'm back at it again though! I don't think that's the issue, I'm outputting PhotonNetwork.networkingPeer.State to a text field and both times before I press "Find Match" I'm "ConnectedToGameserver". The first time it goes "ConnectedToGameserver" > "ConnectedToNameServer" > "Authenticating" > "Joined". The second time though it gets stuck on "ConnectedToNameServer". Any thoughts on what could cause it to get stuck on that? Thaks!
  • stefanplc
    Options
    I ended up figuring it out. I needed to turn offlineMode to true and create a new MainMenu room inside OnDisconnectedFromPhoton. So I'm all set, thanks!