run in backround in Android

Options
Hi, Photon developer team:
I use two version of PUN.
1. android platform, version 1.17, click "home" button, photon disconnection when app run in background.
2. android platform, the latest version, click "home" button, photon connected all the time when app run in background.
problem: I want to the photon disconnect when run in background,
Is there a way to solve my problem by photon?

Thanks!

Comments

  • vadim
    Options
    Hi,
    You can disconnect from server when app looses focus and reconnect when it gets back in foreground:
    PhotonNetwork.Disconnect()
    PhotonNetwork.ConnectUsingSettings("1.0");
  • Hi, vadim:
    Thank you for your reply.
    Disconnect from server when app looses focus may have some problem.
    When I receive a message from my friends, message will display, and then app will loose focus too, I think we shouldn't disconnect the photon when receive a message.
    I want to disconnect photonnetwork when i enter into the background.
    If not disconnect , user will exist in the room all the time, and the user's mirror is dead in the room all the time.
  • vadim
    Options
    I think we shouldn't disconnect the photon when receive a message. I want to disconnect photonnetwork when i enter into the background
    It's hard to satisfy both requirements simultaneously using OnApplicationFocus or OnApplicationPause Unity's methods. May be some more sophisticated logic required to detect where do you switch from app? Anyway it's more android/Unity question.
    Photon client simply gets disconnected automatically by server after about 10 sec. of inactivity. Or you can disconnect it explicitly whenever you want.
  • unitylearner
    Options
    Hi Vadim ,

    Photon client simply gets disconnected automatically by server after about 10 sec. of inactivity.


    I can not see the working for me !!

    can you please look into this once
    http://forum.photonengine.com/discussion/7751/onpause-to-be-called-in-android-phone#latest