/// <summary> /// Called by SteelFilter /// </summary> internal static void RecordLaunchResponse(DateTime timestampUtc) { string filepath = FileLocations.GetCurrentLaunchResponseFilePath(ServerName: GameRepo.Game.Server, AccountName: GameRepo.Game.Account); using (var file = new StreamWriter(filepath, append: false)) { int pid = System.Diagnostics.Process.GetCurrentProcess().Id; file.WriteLine("FileVersion:{0}", LaunchResponse.MASTER_FILE_VERSION); file.WriteLine("TimeUtc: {0:o}", timestampUtc); file.WriteLine("ProcessId:{0}", pid); file.WriteLine("SteelFilterVersion:{0}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version); } }
/// <summary> /// Called by SteelBotLauncher /// </summary> public static LaunchResponse GetLaunchResponse(string ServerName, string AccountName, TimeSpan maxLatency) { var info = new LaunchResponse(); try { string filepath = FileLocations.GetCurrentLaunchResponseFilePath(ServerName: ServerName, AccountName: AccountName); if (string.IsNullOrEmpty(filepath)) { return(info); } if (!File.Exists(filepath)) { return(info); } var settings = (new SettingsFileLoader()).ReadSettingsFile(filepath); info.FileVersion = SettingHelpers.GetSingleStringValue(settings, "FileVersion"); if (!info.FileVersion.StartsWith(LaunchResponse.MASTER_FILE_VERSION_COMPAT)) { throw new Exception(string.Format( "Incompatible launch response file version: {0}", info.FileVersion)); } info.ResponseTime = SettingHelpers.GetSingleDateTimeValue(settings, "TimeUtc"); if (DateTime.UtcNow - info.ResponseTime.ToUniversalTime() >= maxLatency) { return(info); } info.ProcessId = SettingHelpers.GetSingleIntValue(settings, "ProcessId"); info.SteelFilterVersion = SettingHelpers.GetSingleStringValue(settings, "SteelFilterVersion"); info.IsValid = true; } catch (Exception exc) { log.WriteError("GetLaunchResponse exception: {0}", exc); } return(info); }