feat: implement cross-device reading progress synchronization using SignalR and remove legacy quiz generation services.

This commit is contained in:
2026-05-02 19:55:07 +02:00
parent e5611758f1
commit 94ecc7a404
22 changed files with 332 additions and 69 deletions
@@ -0,0 +1,46 @@
using MediatR;
using Microsoft.AspNetCore.SignalR;
using Microsoft.AspNetCore.Authorization;
using NexusReader.Application.Commands.Sync;
namespace NexusReader.Infrastructure.RealTime;
[Authorize]
public class SyncHub : Hub
{
private readonly IMediator _mediator;
public SyncHub(IMediator mediator)
{
_mediator = mediator;
}
public async Task UpdateProgress(string pageId)
{
var userId = Context.UserIdentifier;
if (!string.IsNullOrEmpty(userId))
{
await _mediator.Send(new UpdateReadingProgressCommand(pageId, userId));
}
}
public override async Task OnConnectedAsync()
{
var userId = Context.UserIdentifier;
if (!string.IsNullOrEmpty(userId))
{
await Groups.AddToGroupAsync(Context.ConnectionId, $"User_{userId}");
}
await base.OnConnectedAsync();
}
public override async Task OnDisconnectedAsync(Exception? exception)
{
var userId = Context.UserIdentifier;
if (!string.IsNullOrEmpty(userId))
{
await Groups.RemoveFromGroupAsync(Context.ConnectionId, $"User_{userId}");
}
await base.OnDisconnectedAsync(exception);
}
}