private void RegisterServerRequest(NetworkingPlayer sender, NetworkingStream stream)
{
ushort port = ObjectMapper.Map<ushort>(stream);
int maxPlayers = ObjectMapper.Map<int>(stream);
string name = ObjectMapper.Map<string>(stream);
string gameType = ObjectMapper.Map<string>(stream);
string comment = ObjectMapper.Map<string>(stream);
string password = ObjectMapper.Map<string>(stream);
string sceneName = ObjectMapper.Map<string>(stream);
HostInfo host = null;
try { host = hosts.First(h => h.IpAddress == sender.Ip.Split('+')[0] && h.port == port); }
catch { }
if (host == null)
{
hosts.Add(new HostInfo() { ipAddress = sender.Ip, port = port, maxPlayers = maxPlayers, name = name, gameType = gameType, comment = comment, password = password, sceneName = sceneName, lastPing = DateTime.Now });
Debug.Log("Registered a new server " + sender.Ip.Split('+')[0] + ":" + port);
}
else
{
host.name = name;
host.maxPlayers = maxPlayers;
host.gameType = gameType;
host.comment = comment;
host.password = password;
host.sceneName = sceneName;
host.lastPing = DateTime.Now;
Debug.Log("Updated the registration of a server " + host.IpAddress+ ":" + host.port);
}
socket.Disconnect(sender, "Register Complete");
}