Search Unity

MasterServer which shows only Local Area Hosts

Discussion in 'Multiplayer' started by BogdanDude, Jan 21, 2011.

  1. BogdanDude

    BogdanDude

    Joined:
    Jun 18, 2009
    Posts:
    89
    Hi!

    We're working on a multiplayer enabled game, and we'd like to connect only the devices on the same local area network.

    We're having some problems showing the host list for all the created servers.

    Using the Unity MasterServer, it shows all running multiplayer sessions across the globe in the host list.

    We'd like to offer a similar functionality to the Master Server, where one creates a server, and the other devices see the servers (host) list, but only those on the same local area network.

    We'd rather do this than ask the users to manually input the IP address.

    Can you please tell me what would be the easiest way to achieve this?

    Thanks a lot,
    Bogdan
     
  2. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    Might be able to hack the masterserver solution you're using already -- just filter to show only servers that have the same public IP. Downside to this would be that the user would still need internet connectivity. If you want true LAN support (doesn't need internet/doesn't rely on master server), you'd have to scan your LAN for computers hosting games and I don't know how to do that.
     
  3. JRavey

    JRavey

    Joined:
    May 12, 2009
    Posts:
    2,377
    Just have the client send out a broadcast based request and any available sessions can reply.
     
  4. BogdanDude

    BogdanDude

    Joined:
    Jun 18, 2009
    Posts:
    89
    Thanks JRavey!

    That sounds like the right thing to do. So do you know how to code that in Unity? :)
    Or is there some .Net stuff involved?
     
  5. JRavey

    JRavey

    Joined:
    May 12, 2009
    Posts:
    2,377
    That would most likely be .NET stuff. Each server would have to have a listener of some sort on a known port, right? That is where I would start. Oh, and probably using UDP is a good idea as it is easier to be spammy and you can get replies from every server listening.
     
  6. Lab013

    Lab013

    Joined:
    Oct 22, 2008
    Posts:
    405
    Doesn't the Unity Networking Example have a local master server example?
     
  7. JRavey

    JRavey

    Joined:
    May 12, 2009
    Posts:
    2,377
    Maybe it does, but does a local master server really have that much value?
     
  8. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Not really no, makes no sense at all.
    For in-LAN I wouldn't use it at all, I would use UDP broadcasting to find other games or bonjour
     
  9. BogdanDude

    BogdanDude

    Joined:
    Jun 18, 2009
    Posts:
    89
    Hi Dreamora!

    Thanks for helping out! Do you happen to have some code samples for UDP broadcasting.. or could you point me to some documentation for that?

    I can't really use bonjour... as the game should work on iOS as well as Android and PC/Mac.