Support for master game ID.

This commit is contained in:
Matthew Bowra-Dean
2010-05-28 23:22:08 +12:00
parent 1839655eb5
commit fd014e15a5
9 changed files with 31 additions and 10 deletions

View File

@@ -28,6 +28,7 @@ using System.Net.Sockets;
using System.Security.Cryptography;
using System.Threading;
using OpenRA.FileFormats;
using System.Text;
namespace OpenRA.Server
{
@@ -540,11 +541,14 @@ namespace OpenRA.Server
if (wc.IsBusy || !isInternetServer) return;
var url = "ping.php?port={0}&name={1}&state={2}&players={3}&mods={4}&map={5}";
wc.DownloadDataCompleted += PingMasterServerResponse;
if (isInitialPing)
{
url += "&new=1";
isInitialPing = false;
}
else
wc.DownloadDataCompleted -= PingMasterServerResponse;
wc.DownloadDataAsync(new Uri(
masterServerUrl + url.F(
@@ -556,5 +560,11 @@ namespace OpenRA.Server
lastPing = Environment.TickCount;
}
static void PingMasterServerResponse(object sender, DownloadDataCompletedEventArgs e)
{
string s = Encoding.UTF8.GetString(e.Result);
int.TryParse(s.Trim(), out Game.MasterGameID);
}
}
}