| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using Application.Abstractions.Hub;
- using Infrastructure.Hubs;
- using Web.Api.Common;
- using MediatR;
- using Microsoft.AspNetCore.SignalR;
- namespace Web.Api.Endpoints.Donation;
- /// <summary>후원 리모콘 상태 관리</summary>
- internal sealed class RemoteState : IEndpoint
- {
- public void MapEndpoint(IEndpointRouteBuilder app)
- {
- /// 일시정지/후원수신/음성만/영상만 상태 + 대기열 조회
- app.MapGet("api/donation/remote/state/{widgetToken}", async (
- string widgetToken,
- ISender sender,
- CancellationToken ct
- ) => {
- var data = await sender.Send(new Application.Features.Api.DonationRemote.GetState.Query(widgetToken), ct);
- return ApiResponse.Ok(data);
- })
- .WithTags("DonationRemote")
- .RequireAuthorization();
- /// 리모콘 상태 변경 (isPaused, isAccepting, isAudioOnly, isVideoOnly)
- app.MapPost("api/donation/remote/state", async (
- Application.Features.Api.DonationRemote.UpdateState.Command body,
- ISender sender,
- IHubContext<DonationHub, IDonationHubClient> donationHub,
- CancellationToken ct
- ) => {
- await sender.Send(body, ct);
- // 위젯 + 리모콘 모두에게 상태 변경 broadcast
- await donationHub.Clients.Group(body.WidgetToken).ReceiveState(new
- {
- isPaused = body.IsPaused,
- isAccepting = body.IsAccepting,
- isAudioOnly = body.IsAudioOnly,
- isVideoOnly = body.IsVideoOnly
- });
- return ApiResponse.Ok();
- })
- .WithTags("DonationRemote")
- .RequireAuthorization();
- }
- }
|