Skip to content

Commit

Permalink
fix: resolves issue with lockout timer not being stopped
Browse files Browse the repository at this point in the history
  • Loading branch information
ndorin committed Jun 28, 2024
1 parent ae787d3 commit a6b784b
Showing 1 changed file with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,21 +218,24 @@ private void HandleRoomCombineScenarioChanged()
_mcTpController.UisCiscoCodec.EnqueueCommand(UiWebViewDisplay.xCommandStatus());
if (_mcTpController.EnableLockoutPoll)
{
// Start the timer when lockout occurs
_lockoutPollTimer = new System.Timers.Timer(
_props?.Lockout?.PollIntervalMs > 0 ? _props.Lockout.PollIntervalMs : 5000
);
_lockoutPollTimer.AutoReset = true;
_lockoutPollTimer.Enabled = true;
// Start the timer when lockout occurs
if (_lockoutPollTimer == null)
{
_lockoutPollTimer = new System.Timers.Timer(
_props?.Lockout?.PollIntervalMs > 0 ? _props.Lockout.PollIntervalMs : 5000
);
_lockoutPollTimer.Enabled = false;
_lockoutPollTimer.AutoReset = true;
}
_lockoutPollTimer.Start();
_lockoutPollTimer.Elapsed += (s, a) =>
{
Debug.LogMessage(LogEventLevel.Verbose, "Lockout Poll Timer Elapsed", null, null);
if (!_mcTpController.LockedOut)
{
Debug.LogMessage(LogEventLevel.Verbose, $"_mcTpController.LockedOut: {_mcTpController.LockedOut}", null, null);
//if not in lockout state and was previously locked out
ClearCiscoCodecUiWebViewController();
_extensionsHandler.UiWebViewChanagedEvent -= LockoutUiWebViewChanagedEventHandler;
_lockoutPollTimer.Enabled = false;
_lockoutPollTimer.Dispose();
CancelLockoutTimer();
return;
}
_mcTpController.UisCiscoCodec.EnqueueCommand(UiWebViewDisplay.xCommandStatus());
Expand All @@ -242,8 +245,7 @@ private void HandleRoomCombineScenarioChanged()
return;
}

_extensionsHandler.UiWebViewChanagedEvent -= LockoutUiWebViewChanagedEventHandler;
_mcTpController.LockedOut = false;
CancelLockoutTimer();
Debug.LogMessage(
LogEventLevel.Debug,
$"ui with default room key {_thisUisDefaultRoomKey} is not locked out",
Expand All @@ -268,6 +270,16 @@ private void HandleRoomCombineScenarioChanged()
}
}

private void CancelLockoutTimer()
{
Debug.LogMessage(LogEventLevel.Verbose, $"Canceling Lockout Poll Timer for: {_mcTpController.Key}", null, _mcTpController.Key);
_extensionsHandler.UiWebViewChanagedEvent -= LockoutUiWebViewChanagedEventHandler;
_mcTpController.LockedOut = false;
ClearCiscoCodecUiWebViewController();
_lockoutPollTimer.Stop();
_lockoutPollTimer.Dispose();
}

public void LockoutUiWebViewChanagedEventHandler(object sender, UiWebViewChanagedEventArgs args)
{
bool isError = args?.UiWebViewStatus?.IsError ?? false;
Expand Down

0 comments on commit a6b784b

Please sign in to comment.