Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question How do you detect a lobby user has lost connection on a mobile device?

Discussion in 'Lobby' started by JonLandmark, Aug 16, 2023.

  1. JonLandmark

    JonLandmark

    Joined:
    Jan 15, 2022
    Posts:
    5
    Hi,

    We want the lobby system to handle a user being removed from the lobby on mobile via a loss of internet connection or due to them putting the app into the background. We are using the lobby system where players 'ready up' and then we allocate a dedicated server for the gameplay (We do not use relay).

    We currently have the host sending a heartbeat every 15 seconds along with an active lifespan of 30 seconds and a disconnect removal time of 60 seconds. If the host puts the app into the background, the lobby goes into an inactive state after 30 seconds as expected due to the heartbeat no longer being sent. However, the host never seems to get removed from the users list, the host does not transfer and no lobby event for a user leaving or being kicked gets called on other users devices.

    It seems the only way to get the host to be transferred or to be told about another user leaving is to hard close the app or do it gracefully via the RemovePlayerAsync call. However, if the user is dropping their connection they wouldn't be able to make such a call.

    What is the expected behavior here? Should the lobby system be transferring host if the host drops their connection or backgrounds the app? Should it then be informing other users about the user leaving?
     
    Last edited: Aug 17, 2023
  2. JonLandmark

    JonLandmark

    Joined:
    Jan 15, 2022
    Posts:
    5
    Update to what I have found testing on mobile.

    Using version 1.1.0 of the lobby system and subscribing to lobby events seems to inform other users that a user has left when the app is hard closed. However, it doesn't seem to work when the app is put into the background or when a connection is lost.

    After reading this forum post about reverting, I thought I would try the same. I have tried reverting to 1.1.0-prev.4 and this seems to work for backgrounding and connection loss on IOS and for connection loss on Android. It does not seem to be working on Android for backgrounding.

    Should I expect the Lobby SDK to handle disconnecting and removing users from lobbies and migrating hosts on Android when the app is backgrounded?