From 9d3b1193bf18fda360f97583c299017fa04d8bb0 Mon Sep 17 00:00:00 2001 From: Jared Date: Fri, 2 Oct 2020 15:34:57 -0700 Subject: [PATCH] Stop idle timer while remote control access prompt is displayed. --- Desktop.Core/Services/CasterSocket.cs | 7 +++++++ Desktop.Core/Services/IdleTimer.cs | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/Desktop.Core/Services/CasterSocket.cs b/Desktop.Core/Services/CasterSocket.cs index bf7d104a..39f766be 100644 --- a/Desktop.Core/Services/CasterSocket.cs +++ b/Desktop.Core/Services/CasterSocket.cs @@ -13,10 +13,12 @@ namespace Remotely.Desktop.Core.Services public class CasterSocket { public CasterSocket( + IdleTimer idleTimer, IDtoMessageHandler messageHandler, IScreenCaster screenCastService, IRemoteControlAccessService remoteControlAccessService) { + IdleTimer = idleTimer; MessageHandler = messageHandler; ScreenCaster = screenCastService; RemoteControlAccessService = remoteControlAccessService; @@ -24,6 +26,7 @@ namespace Remotely.Desktop.Core.Services public HubConnection Connection { get; private set; } public bool IsConnected => Connection?.State == HubConnectionState.Connected; + private IdleTimer IdleTimer { get; } private IDtoMessageHandler MessageHandler { get; } private IScreenCaster ScreenCaster { get; } private IRemoteControlAccessService RemoteControlAccessService { get; } @@ -176,7 +179,11 @@ namespace Remotely.Desktop.Core.Services if (enforceAttendedAccess) { await SendMessageToViewer(viewerID, "Asking user for permission..."); + + IdleTimer.Stop(); var result = await RemoteControlAccessService.PromptForAccess(requesterName, organizationName); + IdleTimer.Start(); + if (!result) { await SendConnectionRequestDenied(viewerID); diff --git a/Desktop.Core/Services/IdleTimer.cs b/Desktop.Core/Services/IdleTimer.cs index 229e35ae..807a0915 100644 --- a/Desktop.Core/Services/IdleTimer.cs +++ b/Desktop.Core/Services/IdleTimer.cs @@ -26,6 +26,12 @@ namespace Remotely.Desktop.Core.Services Timer.Start(); } + public void Stop() + { + Timer?.Stop(); + Timer?.Dispose(); + } + private void Timer_Elapsed(object sender, ElapsedEventArgs e) { if (ViewerList.Count > 0)