Return to lobby after leaving game
I'm trying to figure out how to return to a lobby after leaving a game.
My understanding is that when you Join a room, you leave the lobby, leave the master server, and join a room on a game server. So when you leave that room, you are no longer in a lobby and you are connected to a game server so you can't call JoinLobby.
To return to the lobby do I have to disconnect from photon, reconnect, and join the lobby?
Thank you for your time.
Comments
-
Thank you for your help!
WhenOnLeftRoom()
is called, I am not yet on the master server. So I start a coroutine like this:while (PhotonNetwork.Server != ServerConnection.MasterServer || PhotonNetwork.connectionStateDetailed != ClientState.ConnectedToMaster) { yield return null; } ConnectToLobby();
Which gets the job done, but I'm wondering if there is some other callback that I can use?OnConnectedToMaster()
isn't called when leaving a room.0 -
If you enable "Auto Join Lobby" then
OnJoinedLobby
will be triggered instead ofOnConnectedToMaster
Otherwise, if "Auto Join Lobby" is disabledOnConnectedToMaster
is connected.
So you do not need the coroutine inOnLeftRoom
to manually rejoin lobby.
Just wait forOnJoinedLobby
.0 -
I believe I need to have AutoJoinLobby off so I can join a specific lobby. (We're leaning towards using a SQL lobby) When you
LeaveRoom
you're technically going back to master butOnConnectedToMaster
isn't called. Assuming you have AutoJoinLobby off, is there any way to determine when you've returned to the master server so you can join a lobby again?0 -
Maybe you are switching scenes and the callback call is lost during the transition.
Can you try implement all connection callbacks fromIPunCallbacks
(just get the signature from there and add methods to aMonoBehaviour
in the scene or implement interface if you want)0 -
Hello JohnTube and all the other programmers :),
I wanted to ask you how to implement (maybe via script) automatic connection to the lobby instead of the master server? I didn't find a solution for this problem and I am very new to photon...
I hope for a answer soon :)
Vallekralle
Edit:
I found my problem! I tried to join a lobby after Leaving a room immediately (in the "OnLeftRoom"-method). That is a mistake because the client didn't even made it to the point to connect to the master server again. So I had to write the "JoinLobby"-method in the "OnConnectedToMaster"-method. I think that can happen often, if people try to connect their game to the server in one scene and join a lobby in another...
I hope I can help some other lost soul. Have a nice week from germany :),
Vallekralle
0