Search Unity

A web-based game list

Discussion in 'Multiplayer' started by KelsoMRK, Sep 15, 2010.

  1. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Hi folks,

    I've been doing some investigations into using some different technologies to facilitate multiplayer connections and maybe some matchmaking thrown into the mix. The reasoning behind this is that it might be advantageous to have tighter integration between a game's website and the actual game itself. (Think of a community-oriented site where it manages your friends list, win/loss ratio, various other stats from the game but could also allow you to challenge other players to a match while on the message boards or shoutbox etc.) Just wanted to bounce some ideas off the community here.

    -So obviously site stats could be managed via MySQL and PHP by using Unity's WWW class - that part seems fairly straight forward.

    -What I am curious about is using that same method to do some matchmaking and lobby stuff. The idea is that when a user creates a server it pushes some info to a MySQL DB table (ip address, player name, some kind of player rating, whatever else you want). A client looking for a host will query that table in the same manner (conceptually) that MasterServer.RequestHostList() and MasterServer.PollHostList() work. At that point some matchmaking algorithmic magic would occur (for sake of example let's say it just picks the host with the closest player rating to the client). The client then connects to the host and the host's record in the connections table is subsequently removed if the max number of connections has been reached.

    -Where my understanding breaks down is the limits of what is possible inside Unity and what is going on with a Facilitator when it attempts to connect 2 players. Would it be possible to write a C# script (or several) to allow Unity to handle connecting to another player? I would assume that this would be doable if you potentially have access to the System.Net namespace and I've seen some examples floating around of some C# UDP fanciness, but this isn't really my area of expertise.

    Any thoughts?
     
  2. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    So I did a bit of research today when I should have been working and after reading about UPnP, UDP, NAT and port forwarding (along with any other acronyms I could come up with) I'm a bit confused.

    Where exactly does the Master Server/Facilitator stop and Unity's Network.Connect() method begin?

    So the Facilitator determines the user's connection type and subsequently whether or not they need to use NAT when connecting to a server along with several other things. Does the facilitator actually perform the NAT punchthrough when attempting to connect? What is the extent of this? Does the facilitator do any port forwarding or does it just enumerate private IPs - or does it do neither of those things?

    Also, once a client is connected to a server - is Unity holding that connection and doing all the packet jazz or does the master server/facilitator still have a hand in this operation? My understanding was that once a game was "started" (leaving the pregame lobby gui and actually doing Application.LoadLevel() along with MasterServer.UnregisterHost() or whatever other method is employed to let people actually play a game together) that neither server nor players were connected to the Master Server. If this is the case - how does Unity handle packet transfers on private IP addresses?
     
  3. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    The connection tester determines if nat is required or not.

    the facilitator is required to get Network.Connect to work in case of useNAT as it will handle the punchthrough
     
  4. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Thanks for the reply.

    In this particular instance I'm looking at simple 2 player multiplayer - 1 server and 1 client. I wonder if it's worth the effort to try and write something into Unity to facilitate NAT traversal based on the source code of the Master Server/Facilitator - or am I really barking up the wrong tree here?