Reconnecting after disconnect while on background fails
Options
I am implementing a feature where after returning the App from background I would re-connect to Master.
I attempted to do this by doing something similar to this:
However this connection seems to fail.
After this if I try to manually reconnect,
Is there a way to immediately reconnect to MasterServer if returning from the background and the connection has dropped? Seems like if I do it immediately it ends up in a loop? Should I just manually delay it (seems to work) - and if so then how much? I would prefer a robust callback after which I can trust that it is safe to reconnect.
Or am I doing something else wrong here?
I attempted to do this by doing something similar to this:
This is handled in an element that only responds if player is already in the room - so I am not doing this if user manually disconnects etc.
public override void OnDisconnected(DisconnectCause cause) {
PhotonNetwork.ConnectUsingSettings();
}
However this connection seems to fail.
After this if I try to manually reconnect,
This gives me the error:
if (!PhotonNetwork.IsConnectedAndReady) {
PhotonNetwork.ConnectUsingSettings();
}
ConnectUsingSettings() failed. Can only connect while in state 'Disconnected'. Current state: ConnectedNow how is it possible to have the PhotonNetwork be in a state where it is both not "ConnectedAndReady", but still "Connected" so I can't reconnect?
Is there a way to immediately reconnect to MasterServer if returning from the background and the connection has dropped? Seems like if I do it immediately it ends up in a loop? Should I just manually delay it (seems to work) - and if so then how much? I would prefer a robust callback after which I can trust that it is safe to reconnect.
Or am I doing something else wrong here?
0