Search Unity

Resolved Is it possible to check at runtime whether or not Relay is enabled for a given project? If so, how?

Discussion in 'Relay' started by anglerge, Mar 16, 2023.

Thread Status:
Not open for further replies.
  1. anglerge

    anglerge

    Joined:
    Dec 18, 2020
    Posts:
    15
    So, long story short, making a game for a client, using Unity Gaming Services as matchmaking infrastructure (and offering the ability to join/host by entering IP addresses as a fallback), however, the client has said that they only want to run the UGS relay/lobby stuff for a fixed period of time.

    Considering this, I want to be able to make the game itself able to detect whether or not Relay (and Lobby) are currently enabled/disabled at runtime, so I can pre-emptively disable the UI elements that the player uses to do things that use these services (and show a warning that the services are currently disabled), to ensure that players do not get greeted with unhelpful error messages after attempting to start/join a game via the Relay/Lobby matchmaking services, by preventing them from attempting to use these services in the first place when they aren't currently enabled.

    So, is 'checking if Relay/Lobby are currently enabled when the game is launched' doable, and, if so, how would one go about doing that?
     
  2. veleek_unity

    veleek_unity

    Ben Randall Unity Technologies

    Joined:
    Aug 25, 2021
    Posts:
    59
    (Response duplicated from the Lobby Forum)

    Your best bet for something like this is to use the Remote Config service to pass a flag to your clients and tweak the behavior based on the value. This is quick and easy to change, and also has the ability for you to use different configuration for different users/clients so that you could have a subset of clients that can still use Lobby/Relay for testing purposes without allowing everyone in.

    If you need to actively PREVENT clients from using the APIs (or maybe prevent malicious users from bypassing the config check and using them anyway), you could use an Access Policy in parallel with the config value. You can construct an access policy to prevent all calls to specific APIs for a given project. See the Access Control API docs for more detail.
     
  3. veleek_unity

    veleek_unity

    Ben Randall Unity Technologies

    Joined:
    Aug 25, 2021
    Posts:
    59
Thread Status:
Not open for further replies.