Going on background or application lose focus , photon discoonect.

Options
Hi,
In my application when i am connected to photon in android , when my application goes in background, photon disconnect.
Note : I haven't joined any room yet.

How can i again connect to photon when open the application from background?

Comments

  • Hi @Yogesh_Dev,

    when the application is active again, Unity will call OnApplicationPause(bool pauseStatus) or OnApplicationFocus(bool hasFocus). You can use this call, to check if application is still connected to Photon. If it is not connected any longer, you can connect to the service again.
  • Yogesh_Dev
    Options
    Hi @Christian_Simon ,

    I am checking this and calling photonNetwork.Reconnect() when pausestatus is false. but unable to reconnect to photon.
  • Any errors logged to the console or adb?
  • Yogesh_Dev
    Options
    Hi,
    Yes, photonNetwork.icConnectedandReady is always coming false
  • Instead of using Reconnect, did you already try using another connect function? Is there a different result?

    PhotonNetwork.connectedAndReady is true as soon as the client is connected and ready to exchange operations.
  • Yogesh_Dev
    Options
    Yes, if i use another connect function instead of reconnect PhotonNetwork.connectedAndReady is always true.
  • Yogesh_Dev
    Options
    What is the use of Reconnect funtion then?
  • Yogesh_Dev
    Options
    hi,

    One more question, I have created a room. nobody is in the room (except me) then how to destroy room immediately when my internet connection gets off.
  • Until you don't use another value for EmptyRoomTtl (you can set this for example when creating the room by using the RoomOptions), the room gets removed immediately after the last client has left it. If the last client has a timeout, it might take up to 10 seconds before the server 'disconnects' the client and furthermore removes the room.