Search Unity

PollHostList

Discussion in 'Multiplayer' started by Harry Tuttle, Nov 21, 2008.

  1. Harry Tuttle

    Harry Tuttle

    Joined:
    Jan 3, 2006
    Posts:
    122
    How can I distinguish between a call to PollHostList that returns no servers because the call to RequestHostList specified a game type name that doesn't exist, and one that returns no servers because it hasn't been populated yet?
    e.g.

    Code (csharp):
    1.  
    2. function Awake() {
    3.   // Make sure list is empty and request a new list
    4.   MasterServer.ClearHostList();
    5.   MasterServer.RequestHostList("DoesThisGameExist");
    6. }
    7.  
    8. function Update() {
    9.    if (MasterServer.PollHostList().length == 0)
    10.    {
    11.      //does this mean no games exist? or do I still have wait a bit longer?
    12.    }
    13. }
    14.  
     
  2. ProtonOne

    ProtonOne

    Joined:
    Mar 8, 2008
    Posts:
    406
    I don't think there is a way. I put in a timer, if it is still zero after 5 seconds, I just accept that it is likely zero.
     
  3. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728
    I beleive you get an OnFailedToConnectToMasterServer event thrown if the RequestHostList method fails. I can't double check this now, but you can test yourself by building the master server conntester and just shutting it down manually to see if the error occurs.
     
  4. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    I also use the 3-5 seconds waiting time.

    That's true, but it's only throw when the connection really fails. We still have no way of identifying when the server responded with an empty list as you never know how long it takes, even though I'm sure you can assume it doesn't longer than 3 seconds, otherwise it would probably send a fail.

    This is important for features like quickmatch/play-now, where you use the masterserver to decide join an excisting game or host.

    Meh, it just requires my users to wait 3 seconds longer when there are no matches, on witch my "play now" feature will start hosting a game.