Skip to content

Commit

Permalink
Scope loader messages to the circuit connection.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Mar 11, 2024
1 parent 7478d63 commit 686dc78
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Server/Hubs/CircuitConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public async Task<Result<RemoteControlSessionEx>> RemoteControl(string deviceId,
"There are already the maximum amount of active remote control sessions for your organization.",
"Max number of concurrent sessions reached.",
"bg-warning");

await _messenger.Send(message, ConnectionId);

return Result.Fail<RemoteControlSessionEx>("Max number of concurrent sessions reached.");
Expand Down
16 changes: 4 additions & 12 deletions Server/Services/LoaderService.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using Immense.RemoteControl.Shared.Primitives;
using Immense.SimpleMessenger;
using Remotely.Server.Hubs;
using Remotely.Server.Models.Messages;
using System;
using System.Threading.Tasks;

namespace Remotely.Server.Services;

Expand All @@ -12,23 +11,16 @@ public interface ILoaderService
void HideLoader();
}

public class LoaderService : ILoaderService
public class LoaderService(IMessenger _messenger, ICircuitConnection _circuitConnection) : ILoaderService
{
private readonly IMessenger _messenger;

public LoaderService(IMessenger messenger)
{
_messenger = messenger;
}

public async Task<IDisposable> ShowLoader(string statusMessage)
{
await _messenger.Send(new ShowLoaderMessage(true, statusMessage));
await _messenger.Send(new ShowLoaderMessage(true, statusMessage), _circuitConnection.ConnectionId);
return new CallbackDisposable(HideLoader);
}

public void HideLoader()
{
_messenger.Send(new ShowLoaderMessage(false, string.Empty));
_messenger.Send(new ShowLoaderMessage(false, string.Empty), _circuitConnection.ConnectionId);
}
}

0 comments on commit 686dc78

Please sign in to comment.