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 What does the "maxConnections" value in the "CreateAllocationAsync" method do?

Discussion in 'Relay' started by Mj-Kkaya, Apr 2, 2023.

  1. Mj-Kkaya

    Mj-Kkaya

    Joined:
    Oct 10, 2017
    Posts:
    156
    Hi,

    I'am working with relay for understanding its structure.
    I couldn't quite understand what the maxConnections value of CreateAllocationAsync does.

    When I set maxConnections to 1 or 2 it doesn't create any restrictions.
    More players than maxConnections can join the Relay with the same join code.

    await RelayService.Instance.CreateAllocationAsync(1, region);

    So, why we use maxConnections?

    Thanks.
     
  2. BGagnon_Unity

    BGagnon_Unity

    Unity Technologies

    Joined:
    Mar 9, 2022
    Posts:
    5
    Connection enforcement happens when the connection to the host through the relay is requested. This is not the same as joining (and binding to) the Relay. The connection happens through a CONNECT_REQUEST message. This is handled by Unity Transport Package and the NetworkManager.

    https://docs.unity.com/relay/en/manual/relay-message-protocol#CONNECT_
     
  3. Mj-Kkaya

    Mj-Kkaya

    Joined:
    Oct 10, 2017
    Posts:
    156
    Thanks for your answer.

    If I corretly understand, maxConnections value isn't restriction for joining the relay server as a client and
    this value is used when the "host player" create a "relay server" allocation.

    Is this mean, Server uses maxConnections value to create "relay server" in appropriate/avaiable place?