SEBWIN-535: Implemented configuration mapping for ping interval of server proxy.

This commit is contained in:
Damian Büchel 2022-01-03 17:38:15 +01:00
parent 0abbef749e
commit 5d5e15e522
5 changed files with 19 additions and 1 deletions

View file

@ -26,6 +26,9 @@ namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
case Keys.Server.PerformFallback: case Keys.Server.PerformFallback:
MapPerformFallback(settings, value); MapPerformFallback(settings, value);
break; break;
case Keys.Server.PingInterval:
MapPingInterval(settings, value);
break;
case Keys.Server.RequestAttempts: case Keys.Server.RequestAttempts:
MapRequestAttempts(settings, value); MapRequestAttempts(settings, value);
break; break;
@ -88,6 +91,14 @@ namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
} }
} }
private void MapPingInterval(AppSettings settings, object value)
{
if (value is int interval)
{
settings.Server.PingInterval = interval;
}
}
private void MapRequestAttempts(AppSettings settings, object value) private void MapRequestAttempts(AppSettings settings, object value)
{ {
if (value is int attempts) if (value is int attempts)

View file

@ -254,6 +254,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
settings.Security.KioskMode = KioskMode.CreateNewDesktop; settings.Security.KioskMode = KioskMode.CreateNewDesktop;
settings.Security.VirtualMachinePolicy = VirtualMachinePolicy.Deny; settings.Security.VirtualMachinePolicy = VirtualMachinePolicy.Deny;
settings.Server.PingInterval = 1000;
settings.Server.RequestAttemptInterval = 2000; settings.Server.RequestAttemptInterval = 2000;
settings.Server.RequestAttempts = 5; settings.Server.RequestAttempts = 5;
settings.Server.RequestTimeout = 30000; settings.Server.RequestTimeout = 30000;

View file

@ -296,6 +296,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
internal const string FallbackPasswordHash = "sebServerFallbackPasswordHash"; internal const string FallbackPasswordHash = "sebServerFallbackPasswordHash";
internal const string Institution = "institution"; internal const string Institution = "institution";
internal const string PerformFallback = "sebServerFallback"; internal const string PerformFallback = "sebServerFallback";
internal const string PingInterval = "pingInterval";
internal const string RequestAttempts = "sebServerFallbackAttempts"; internal const string RequestAttempts = "sebServerFallbackAttempts";
internal const string RequestAttemptInterval = "sebServerFallbackAttemptInterval"; internal const string RequestAttemptInterval = "sebServerFallbackAttemptInterval";
internal const string RequestTimeout = "sebServerFallbackTimeout"; internal const string RequestTimeout = "sebServerFallbackTimeout";

View file

@ -333,7 +333,7 @@ namespace SafeExamBrowser.Server
pingTimer.AutoReset = false; pingTimer.AutoReset = false;
pingTimer.Elapsed += PingTimer_Elapsed; pingTimer.Elapsed += PingTimer_Elapsed;
pingTimer.Interval = 1000; pingTimer.Interval = settings.PingInterval;
pingTimer.Start(); pingTimer.Start();
logger.Info("Started sending pings."); logger.Info("Started sending pings.");

View file

@ -51,6 +51,11 @@ namespace SafeExamBrowser.Settings.Server
/// </summary> /// </summary>
public bool PerformFallback { get; set; } public bool PerformFallback { get; set; }
/// <summary>
/// The time interval in milliseconds to be used for ping requests.
/// </summary>
public int PingInterval { get; set; }
/// <summary> /// <summary>
/// The number of attempts (e.g. when receiving an invalid server response) before performing a fallback or failing. /// The number of attempts (e.g. when receiving an invalid server response) before performing a fallback or failing.
/// </summary> /// </summary>