Added try/catch to transport update loop
This commit is contained in:
parent
b84448ea11
commit
63de39ebf7
1 changed files with 24 additions and 16 deletions
|
|
@ -106,10 +106,10 @@ namespace LightReflectiveMirror
|
|||
_currentConnections.Remove(clientID);
|
||||
_relay.HandleDisconnect(clientID);
|
||||
|
||||
if(NATConnections.ContainsKey(clientID))
|
||||
if (NATConnections.ContainsKey(clientID))
|
||||
NATConnections.Remove(clientID);
|
||||
|
||||
if(_pendingNATPunches.TryGetByFirst(clientID, out _))
|
||||
if (_pendingNATPunches.TryGetByFirst(clientID, out _))
|
||||
_pendingNATPunches.Remove(clientID);
|
||||
};
|
||||
|
||||
|
|
@ -150,12 +150,12 @@ namespace LightReflectiveMirror
|
|||
{
|
||||
natThread.Start();
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
WriteLogMessage("FAILED\n" + e, ConsoleColor.DarkRed);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
WriteLogMessage("FAILED\nCheck if port is in use.", ConsoleColor.DarkRed, true);
|
||||
Console.WriteLine(e);
|
||||
|
|
@ -169,7 +169,7 @@ namespace LightReflectiveMirror
|
|||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
WriteLogMessage("FAILED\nException: " + e, ConsoleColor.DarkRed);
|
||||
Console.ReadKey();
|
||||
|
|
@ -181,17 +181,25 @@ namespace LightReflectiveMirror
|
|||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_updateMethod != null) _updateMethod.Invoke(transport, null);
|
||||
if (_lateUpdateMethod != null) _lateUpdateMethod.Invoke(transport, null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
WriteLogMessage("Error During Transport Update! " + e, ConsoleColor.Red);
|
||||
}
|
||||
|
||||
|
||||
_currentHeartbeatTimer++;
|
||||
|
||||
if(_currentHeartbeatTimer >= conf.UpdateHeartbeatInterval)
|
||||
if (_currentHeartbeatTimer >= conf.UpdateHeartbeatInterval)
|
||||
{
|
||||
_currentHeartbeatTimer = 0;
|
||||
|
||||
for(int i = 0; i < _currentConnections.Count; i++)
|
||||
for (int i = 0; i < _currentConnections.Count; i++)
|
||||
transport.ServerSend(_currentConnections[i], 0, new ArraySegment<byte>(new byte[] { 200 }));
|
||||
|
||||
if (conf.UseLoadBalancer)
|
||||
|
|
@ -220,7 +228,7 @@ namespace LightReflectiveMirror
|
|||
await wc.DownloadStringTaskAsync($"http://{conf.LoadBalancerAddress}:{conf.LoadBalancerPort}/api/roomsupdated");
|
||||
}
|
||||
}
|
||||
catch {} // LLB might be down, ignore.
|
||||
catch { } // LLB might be down, ignore.
|
||||
}
|
||||
|
||||
private async Task<bool> RegisterSelfToLoadBalancer()
|
||||
|
|
|
|||
Loading…
Reference in a new issue