Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Resolved How do you do player count and ping without joining the server?

Discussion in 'Multiplayer' started by protomor, Nov 12, 2023.

  1. protomor

    protomor

    Joined:
    Dec 13, 2021
    Posts:
    38
    So many games have boards of servers with player counts and average ping. I don't see a way to do that in mirror without actually connecting to the server. I can kinda figure out ping but that doesn't tell you if the server is up or not. I was told to make the servers call an external service but that seems like more work that it needs to be. How do others do it?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    7,263
    There is only two ways: connect to the server (temporarily) and get that data. Or have servers push their stats to a central web server that clients can poll via web requests.
     
  3. Welfarecheck

    Welfarecheck

    Joined:
    Jun 14, 2020
    Posts:
    122
    In Fishnet, a lot of folks use FishMMO. A community driven modular framework for large scale MMOs.https://github.com/jimdroberts/FishMMO/

    Check out their discord if you have specific questions about it. Super friendly folks.

    The same idea apply to all the other networking solutions. So, you can get a good grip by looking at how they made the framework.

    Start with a central login server that maintains authentication, character creation, world selection, etc. and move players to servers as needed while aggregating information to the central server. The login server can have 10s of thousands of users and you can have Nth login servers as needed to scale the game. The login server does very simple tasks so it can handle a considerable amount of users at a 1-2 tick rate compared to a game world that has physics simulations and whatnot at 15+ tick rate.

    Another option is to push to a web server to show stats and whatnot. Bit more work.
     
  4. protomor

    protomor

    Joined:
    Dec 13, 2021
    Posts:
    38
    I'm using mirror. I have a secondary application that I'm trying to connect to the server temporarily with but it rejects the connection. I should probably figure out why.

    A central server kind of makes sense, still would be hard to do pinging with but also adds cost and complexity. Thanks for the input guys.
     
  5. Welfarecheck

    Welfarecheck

    Joined:
    Jun 14, 2020
    Posts:
    122
    Hmm, should be a way in Mirror, somewhere with the ticks. If not, you can always use 2 RPCs, 1 from the server to the client with time of the RPC, RPC back to the server from the client, divide by 2, and multiply by 1000. Probably a good idea to average it over 5 seconds or something.