| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using Application.Abstractions.Hub;
- using Infrastructure.Hubs;
- using Web.Api.Common;
- using MediatR;
- using Microsoft.AspNetCore.SignalR;
- namespace Web.Api.Endpoints.Donation;
- /// <summary>리모콘 — 건너뛰기 (현재 재생 중 알림 즉시 종료 + 위젯/리모콘 broadcast)</summary>
- internal sealed class RemoteSkip : IEndpoint
- {
- public void MapEndpoint(IEndpointRouteBuilder app)
- {
- app.MapPost("api/donation/remote/skip/{widgetToken}", async (
- string widgetToken,
- ISender sender,
- IHubContext<DonationHub, IDonationHubClient> donationHub,
- CancellationToken ct
- ) => {
- var result = await sender.Send(new Application.Features.Api.DonationRemote.SkipCurrent.Command(widgetToken), ct);
- if (result.IsFailure)
- {
- return CustomResults.Problem(result);
- }
- // 위젯: 현재 알림 즉시 unmount + 다음 알림 진입. 리모콘: 행 상태를 skipped 로 갱신.
- await donationHub.Clients.Group(widgetToken).ReceiveSkip();
- if (result.Value.SkippedAlertID is int skippedID)
- {
- await donationHub.Clients.Group(widgetToken).ReceiveAlertStatusUpdate(new
- {
- alertID = skippedID,
- status = "skipped"
- });
- }
- return ApiResponse.Ok();
- })
- .WithTags("DonationRemote")
- .RequireAuthorization();
- }
- }
|