I realized the masterserver I wrote for PHP would also work pretty easily in the google app engine. So I did that. The code is here: GitHub - tosos/PHPMasterServer: A Master Server for Unity3d v3 that runs in PHP. (except you only need MainMenu.js PyMasterServerConnect.js and masterServer.py) In your app.yaml add the following to the “handlers” section:
url: /masterserver/.*
script: masterServer.py
One of the nice advantages of putting this on Google’s stuff is that you can get some really nice server localization without worrying about where people are connecting from. You could even get wild and use the HighReplication when it comes out to get really low latency all over the world at the same time
I’ve been looking for information about networked multiplayer and this could be great! Does it work? (hehe) What kind of games have you tried with that masterserver?
I use it in this one: http://apps.facebook.com/WhoCutTheDeck and in the multiplayer setup for the RisingStorm test builds http://www.tosos.com/RisingStormTest.html The master server is only responsible for showing a list of games you can join and gets you connected, the rest of the multiplayer is something else entirely…
I might give this a go,
But one question if you don’t mind, this master server is only responsible to show a list of games, but you don’t use nothing of unity master server for this ? I have seen some php masterservers around here that still require unity’s master server.
And once your player gets the lists of games, how do you make the connection ? One of them still has to be the server and other one the client for a p2p connection ? And how do you make them connect if most people are behind routers ?
From what I understand one of the advantages of Unity’s masterserver is the facilitator and the NAT pounchtrough functionality…,
Sorry to post so many questions, I’m still a bit uncertain on what to do regarding my multiplayer options.
Thanks
It’s precisely what I’m looking for: a way to allow people to find games they can join. Now please answer BigB’s questions, because they are also mine!
This one works exactly like the php master server, except on the app engine. The reason they still call the normal RegisterHost() is to setup the external ip which is necessary for nat tunneling, but it doesn’t actually need to store the host or lookup hosts, since that part is taken care of by the php or app engine. When the connection takes place it is independent of any servers and just involves the two players’ machines. But if it needs nat tunneling, it has the external ip setup as needed.
I haven’t checked carefully on 3 (I wrote it originally in 2.6) whether pinging unity’s masterserver is still necessary. It works with 3, but that ping might be an extra unnecessary step.
No matter what, this will still use the nat facilitator which is part of unity’s master server code, but on a separate port. My original intention for this was to replace only the host list part, since I found it pretty laggy to use unity’s server and couldn’t run my own on my provider. Hosting it via app engine has some nice benefits for avoiding lag.
Mmmmargh. I’ve been trying to setup all this with my own app, with no success. I’ve already deployed your master server in google app engine, and then I use the ConnectGUI script example from the ‘official’ networking example (http://unity3d.com/support/resources/example-projects/networking-example.html) to connect with it.
While the whole thing works locally (that is, a build is able to connect to the server, which is running in Unity’s editor in 127.0.0.1:25000), it simply does nothing when trying to connect to my GAE app.
I’m totally lost with all this. Just in case you want to try, your master server was deployed here: http://cuentateuno.appspot.com
Edit: I’ve just realized that those scripts were prepared to connect machines directly, not through a master server… I’ll try again this afternoon
Ok, I installed locally your GAE master server, and it worked perfectly. I was able to create a server and connect to it through the master server in http://localhost. But I simply can’t connect to the one I installed in appspot.
Nevertheless, the NAT punch-through problem is a huge barrier in all this. I just can’t afford a server to install my own facilitator, so I fear I’ll have to drop the multiplayer idea for the time being
If I may jump in and ask for some clarifications, is the following true?
Duhprey’s code acts as a match-making service for clients. It runs on GAE. However, it is not capable of NAT punchthrough. If you want punchthrough you need to have another server to act as Facilitator.
For testing with punchthrough can you use the GAE for matchmaking and use the MasterServer run by Unity for Facilitation?
If, in release you need to rent an additional server for punchthrough why bother using the GAE at all? Why not running everything on the server you are renting?
Totally correct, pakfront. At first I was interested in GAE, until I found that I still needed the Facilitator. Then I became interested in my own server. At first I thought it would be too expensive, because I thought I needed a dedicated one. But it seems it’s enough with a virtual server, so I may rent a cheap one and, if people play and like the game, upgrade. Obviously, I would install everything on that server : )
to add clarification, you don’t need registerhost to unity’s master server at all (even though the current mainmenu script calls it), you just need the natfacilitator and connection tester. If you set usenat true in your server init it’ll try to talk to the facilitator independent of either masterserver. I’m not sure what the bandwidth savings are in the long run (I’m using amazons micro instance … so far so good, but nobody is playing so that doesn’t tell me much :)),
I pretty much just made this and the php version as an option to save some bandwidth and use cheaper services for the masterserver part (also slightly easier to setup if all you have open is port 80).
I still need to go in and fix up the code on github to reflect my latest version… I’ve been too busy with the kongregate contest
duhprey, did you updated your code on github? So, are you using GAE for match-making and Amazon Web Services for the Facilitator?
Sorry, I still don’t get it. Can I use GAE for the facilitator too?
You do still need the facilitator running on a real server like unity’s. Of course once you go other your own server there’s not much use to running this master server unless you like python for adding in customizations