Game Center host

Discussion in 'iOS Programming' started by glenncal, Oct 21, 2011.

  1. glenncal, Oct 21, 2011
    Last edited: Oct 21, 2011

    glenncal macrumors member

    Joined:
    Jun 7, 2009
    #1
    I am currently creating a Game Center game, and am using the peer-to-peer functionality available. However, I would like to select one of the players (2 players) to act as a host, to ensure synchronization.
    What is the best way to select a host (even randomly) from the players available and ensure that the other device knows which host was chosen?
     
  2. lefooey macrumors member

    Joined:
    Dec 26, 2009
    Location:
    Spokane, WA
    #2
    Old school method is to for each to choose a random number prior to negotiation. Highest number when they connect becomes the host. You can also then bias the random number method to rank the more capable device higher - such as iPhone 4 ranks higher than iPod 3rd Gen, but not higher than iPad 2. Build in future proofing by setting the bias to a high number and then lowering it to values based on known devices.
     
  3. glenncal thread starter macrumors member

    Joined:
    Jun 7, 2009
    #3
    Thank you :) I'd been trying to find a persistent player id to compare, so I never came close to thinking this.
     
  4. thedollarhunter macrumors member

    Joined:
    May 9, 2011
    Location:
    UK
    #4
    Very smart, that will do me nicely!

     

Share This Page