Fixed a bug that would prevent auto processes from sending through broadcast messages to the clients.

This commit is contained in:
Brett Hewitson 2022-03-22 20:01:50 +10:00
parent 8d84f67bd9
commit 9d4d49560e
12 changed files with 107 additions and 78 deletions

View file

@ -27,7 +27,7 @@ namespace ServerManagerTool.Lib
public int RCONPort { get; set; }
public string AdminPassword { get; set; }
public string RCONPassword { get; set; }
public int MaxPlayers
{

View file

@ -2550,6 +2550,18 @@ namespace ServerManagerTool.Lib
Debug.WriteLine($"[INFO] (Branch {GetBranchName(branchName) ?? "unknown"}) {message}");
}
private void LogProfileDebug(string message, bool includeProgressCallback = true)
{
message = message ?? string.Empty;
_loggerProfile?.Debug(message);
if (includeProgressCallback)
ProgressCallback?.Invoke(0, $"{message}");
Debug.WriteLine($"[DEBUG] (Profile {_profile?.ProfileName ?? "unknown"}) {message}");
}
private void LogProfileError(string error, bool includeProgressCallback = true)
{
if (string.IsNullOrWhiteSpace(error))
@ -2721,37 +2733,27 @@ namespace ServerManagerTool.Lib
var server = QueryMaster.ServerQuery.GetServerInstance(QueryMaster.EngineType.Source, endPoint, sendTimeOut: 10000, receiveTimeOut: 10000);
if (server == null)
{
#if DEBUG
LogProfileMessage($"FAILED: {nameof(SetupRconConsole)} - ServerQuery could not be created.", false);
#endif
LogProfileDebug($"FAILED: {nameof(SetupRconConsole)} - ServerQuery could not be created.", false);
return;
}
#if DEBUG
LogProfileMessage($"SUCCESS: {nameof(SetupRconConsole)} - ServerQuery was created.", false);
#endif
LogProfileDebug($"SUCCESS: {nameof(SetupRconConsole)} - ServerQuery was created.", false);
Task.Delay(1000).Wait();
_rconConsole = server.GetControl(_profile.AdminPassword);
_rconConsole = server.GetControl(_profile.RCONPassword);
if (_rconConsole == null)
{
#if DEBUG
LogProfileMessage($"FAILED: {nameof(SetupRconConsole)} - RconConsole could not be created ({_profile.AdminPassword}).", false);
#endif
LogProfileDebug($"FAILED: {nameof(SetupRconConsole)} - RconConsole could not be created ({_profile.RCONPassword}).", false);
return;
}
#if DEBUG
LogProfileMessage($"SUCCESS: {nameof(SetupRconConsole)} - RconConsole was created ({_profile.AdminPassword}).", false);
#endif
LogProfileDebug($"SUCCESS: {nameof(SetupRconConsole)} - RconConsole was created ({_profile.RCONPassword}).", false);
}
catch (Exception ex)
{
#if DEBUG
LogProfileMessage($"ERROR: {nameof(SetupRconConsole)}\r\n{ex.Message}", false);
LogProfileMessage($"ERROR: {nameof(SetupRconConsole)}\r\n{ex.StackTrace}", false);
#endif
LogProfileDebug($"ERROR: {nameof(SetupRconConsole)}\r\n{ex.Message}", false);
LogProfileDebug($"ERROR: {nameof(SetupRconConsole)}\r\n{ex.StackTrace}", false);
}
}

View file

@ -25,12 +25,13 @@ namespace ServerManagerTool.Lib
public int QueryPort;
public bool RCONEnabled;
public int RCONPort;
public string RCONPassword;
public string ServerMap;
public string ServerMapModId;
public string TotalConversionModId;
public IEnumerable<string> ServerModIds;
public string MOTD;
public int MotDDuration;
public int MOTDDuration;
public bool MOTDIntervalEnabled;
public int MOTDInterval;
public bool ForceRespawnDinos;
@ -75,12 +76,13 @@ namespace ServerManagerTool.Lib
QueryPort = profile.QueryPort,
RCONEnabled = profile.RCONEnabled,
RCONPort = profile.RCONPort,
RCONPassword = profile.AdminPassword,
ServerMap = ServerProfile.GetProfileMapName(profile),
ServerMapModId = ServerProfile.GetProfileMapModId(profile),
TotalConversionModId = profile.TotalConversionModId ?? string.Empty,
ServerModIds = ModUtils.GetModIdList(profile.ServerModIds),
MOTD = profile.MOTD,
MotDDuration = Math.Max(profile.MOTDDuration, 10),
MOTDDuration = Math.Max(profile.MOTDDuration, 10),
MOTDIntervalEnabled = profile.MOTDInterval.HasValue && !string.IsNullOrWhiteSpace(profile.MOTD),
MOTDInterval = Math.Max(1, Math.Min(int.MaxValue, profile.MOTDInterval.Value)),
ForceRespawnDinos = profile.ForceRespawnDinos,

View file

@ -197,7 +197,7 @@ namespace ServerManagerTool.Lib
var endpoint = new IPEndPoint(this.rconParams.RCONHostIP, this.rconParams.RCONPort);
var server = QueryMaster.ServerQuery.GetServerInstance(QueryMaster.EngineType.Source, endpoint);
this.console = server.GetControl(this.rconParams.AdminPassword);
this.console = server.GetControl(this.rconParams.RCONPassword);
return this.console != null;
}
@ -473,7 +473,7 @@ namespace ServerManagerTool.Lib
}
this.maxCommandRetries = 10;
_errorLogger.Error($"Failed to connect to RCON at {this.rconParams.RCONHostIP}:{this.rconParams.RCONPort} with {this.rconParams.AdminPassword}. {lastException.Message}");
_errorLogger.Error($"Failed to connect to RCON at {this.rconParams.RCONHostIP}:{this.rconParams.RCONPort} with {this.rconParams.RCONPassword}. {lastException.Message}");
throw new Exception($"Command failed to send after {maxCommandRetries} attempts. Last exception: {lastException.Message}", lastException);
}
#endregion

View file

@ -1113,7 +1113,7 @@ namespace ServerManagerTool.Lib
Task.Delay(1000).Wait();
_rconConsole = server.GetControl(this.ProfileSnapshot.AdminPassword);
_rconConsole = server.GetControl(this.ProfileSnapshot.RCONPassword);
}
catch (Exception)
{