Catch and ignore BeaconLib errors
This commit is contained in:
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
{
|
{
|
||||||
// 3 minutes. Server has a 5 minute TTL for games, so give ourselves a bit of leeway.
|
// 3 minutes. Server has a 5 minute TTL for games, so give ourselves a bit of leeway.
|
||||||
const int MasterPingInterval = 60 * 3;
|
const int MasterPingInterval = 60 * 3;
|
||||||
static readonly Beacon LanGameBeacon = new Beacon("OpenRALANGame", (ushort)new Random(DateTime.Now.Millisecond).Next(2048, 60000));
|
static readonly Beacon LanGameBeacon;
|
||||||
static readonly Dictionary<int, string> MasterServerErrors = new Dictionary<int, string>()
|
static readonly Dictionary<int, string> MasterServerErrors = new Dictionary<int, string>()
|
||||||
{
|
{
|
||||||
{ 1, "Server port is not accessible from the internet." },
|
{ 1, "Server port is not accessible from the internet." },
|
||||||
@@ -40,6 +40,18 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
volatile bool isBusy;
|
volatile bool isBusy;
|
||||||
Queue<string> masterServerMessages = new Queue<string>();
|
Queue<string> masterServerMessages = new Queue<string>();
|
||||||
|
|
||||||
|
static MasterServerPinger()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
LanGameBeacon = new Beacon("OpenRALANGame", (ushort)new Random(DateTime.Now.Millisecond).Next(2048, 60000));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Write("server", "BeaconLib.Beacon: " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Tick(S server)
|
public void Tick(S server)
|
||||||
{
|
{
|
||||||
if ((Game.RunTime - lastPing > MasterPingInterval * 1000) || isInitialPing)
|
if ((Game.RunTime - lastPing > MasterPingInterval * 1000) || isInitialPing)
|
||||||
@@ -52,7 +64,7 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
|
|
||||||
public void ServerStarted(S server)
|
public void ServerStarted(S server)
|
||||||
{
|
{
|
||||||
if (!server.Ip.Equals(IPAddress.Loopback))
|
if (!server.Ip.Equals(IPAddress.Loopback) && LanGameBeacon != null)
|
||||||
LanGameBeacon.Start();
|
LanGameBeacon.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +80,9 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
|
|
||||||
public void GameEnded(S server)
|
public void GameEnded(S server)
|
||||||
{
|
{
|
||||||
|
if (LanGameBeacon != null)
|
||||||
LanGameBeacon.Stop();
|
LanGameBeacon.Stop();
|
||||||
|
|
||||||
PublishGame(server);
|
PublishGame(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,6 +100,7 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
var clients = server.LobbyInfo.Clients.Where(c1 => c1.Bot == null).Select(c => Convert.ToBase64String(Encoding.UTF8.GetBytes(c.Name))).ToArray();
|
var clients = server.LobbyInfo.Clients.Where(c1 => c1.Bot == null).Select(c => Convert.ToBase64String(Encoding.UTF8.GetBytes(c.Name))).ToArray();
|
||||||
|
|
||||||
UpdateMasterServer(server, numPlayers, numSlots, numBots, numSpectators, mod, passwordProtected, clients);
|
UpdateMasterServer(server, numPlayers, numSlots, numBots, numSpectators, mod, passwordProtected, clients);
|
||||||
|
if (LanGameBeacon != null)
|
||||||
UpdateLANGameBeacon(server, numPlayers, numSlots, numBots, numSpectators, mod, passwordProtected);
|
UpdateLANGameBeacon(server, numPlayers, numSlots, numBots, numSpectators, mod, passwordProtected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,9 +112,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
Game.LoadWidget(null, "GLOBALCHAT_PANEL", widget.Get("GLOBALCHAT_ROOT"), new WidgetArgs());
|
Game.LoadWidget(null, "GLOBALCHAT_PANEL", widget.Get("GLOBALCHAT_ROOT"), new WidgetArgs());
|
||||||
|
|
||||||
lanGameLocations = new List<BeaconLocation>();
|
lanGameLocations = new List<BeaconLocation>();
|
||||||
|
try
|
||||||
|
{
|
||||||
lanGameProbe = new Probe("OpenRALANGame");
|
lanGameProbe = new Probe("OpenRALANGame");
|
||||||
lanGameProbe.BeaconsUpdated += locations => lanGameLocations = locations;
|
lanGameProbe.BeaconsUpdated += locations => lanGameLocations = locations;
|
||||||
lanGameProbe.Start();
|
lanGameProbe.Start();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Write("debug", "BeaconLib.Probe: " + ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
RefreshServerList();
|
RefreshServerList();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user