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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to have server refuse connections from new players

Discussion in 'Multiplayer' started by soaring, Jun 15, 2016.

  1. soaring

    soaring

    Joined:
    Jun 22, 2015
    Posts:
    27
    I have a networked multiplayer match game, where based on the state of the match (as determined by the server), I want to refuse new client connection requests. So, for example if the match is already in progress, new players can't join until the match is over.

    We are using the new networking API, the problem is I can't seem to find where in the API I can process a connection request and refuse a connection. All the triggers/hooks I can find all relates to responding to connections *after* the players have already connected.

    Many thanks!
    Andrew
     
  2. Severos

    Severos

    Joined:
    Oct 2, 2015
    Posts:
    181
    Why not simply disconnect the new client from the OnServerConnect event? I don't think blocking clients is available in the API, but if you disconnect them soon as they connect it really wouldn't affect the game since they don't get to receive any info.
     
  3. soaring

    soaring

    Joined:
    Jun 22, 2015
    Posts:
    27
    Thanks! I can give that a look as well!

    Another option that we were able to find is under NetworkManager Component-> Spawn Info -> Advanced Configuration there is a "Max Connections" properties. Setting that value appears to do what we needed.