I was pondering about networking today, I’ve actually never done any real networking so maybe this gonna be stupid and premature, but I think I understand the basics of it.
Unity allows you to connect to
A: Unity Tech’s Master Server, which gives you a list of IPs for other users who are hosting their own games that you can in turn connect to.
B: Any computer that is running a Unity-built app which is set up to connect to the one you are running.
So, for example, if I built a simple chat program that always connects to IP X, if I put it on the computer that has IP X, start it, and then put it on another computer, the two can chat with eachother.
If that’s the case, can’t I host my own “Master Server”, if I wanted to? Just publish a game that connects to my home computer by default and run a special version of that game on my home computer all day which saves user’s game data and hands out lists of IPs for games. That should work until I move or my house burns down, right? Even if I do move, maybe I put a feature in the game that allows the user to type in a new server IP or looks on a web page for the current server IP.
The other thing I was wondering about is if it is possible to switch out who the server is and who the clients are within a group of say, 4 computers.
Say that I am starting a game with 4 people. We all entered a matchmaking queue, and one of us was chosen to be the “server” by the master server. Early on in the game, that person pulls out their ethernet cable, but the other 3 still want to play. Could the 3 lost and confused computers somehow reconnect to eachother, perhaps with the help of the master server?
The last question is, would it be possible to build some sort of redundancy into the equation so that in a 4 player game, one person is the server, 3 are connected to him, but all 4 have a secondary connection to either one of the 3 clients or a 5th user who is in an entirely different game, and a tertiary connection and so on. That way if one person disconnects, the server-ball gets instantly passed on to someone else and the game goes on.
The other reasoning behind this is anti-hack. For example if two players are in a matchmaking queue for 1v1, both clients are assigned to a random 3rd player who gets to be the “server”, that 3rd player can control which packets to send to each player based on where his units are on the map, meaning that he won’t even get packets he could use in a client hack to reveal the opponent. (say that it is a real time strategy game with fog of war)
Meanwhile the 3rd player doesn’t even notice that he is doing this, and if he disconnects, he is instantly replaced by someone else who was selected as a backup when the game started.