Update: Combined Endpoints to do correct jobs.

This commit is contained in:
2026-04-03 09:35:07 -04:00
parent 701e30c31b
commit 776889932e
2 changed files with 22 additions and 67 deletions

View File

@@ -6,30 +6,23 @@ namespace RelayServer.Endpoints;
public static class RtcEndpoints
{
/// <summary>
/// Maps all RTC-related HTTP endpoints used for joining calls, storing offers and answers,
/// writing ICE candidates, and leaving active calls.
/// Maps all RTC-related HTTP endpoints used for storing offers and answers,
/// writing ICE candidates, checking active calls, and leaving active calls.
/// </summary>
/// <param name="app">The web application to map endpoints onto.</param>
public static void MapRtcEndpoints(this WebApplication app)
{
// Join a channel call and determine whether the caller should become the offerer.
//TODO: Remove join endpoint and redo its logic in correct locations
app.MapPost("/api/rtc/join", async (RtcJoinRequest request, RtcCallService rtcCallService) =>
{
return Results.Ok(await rtcCallService.JoinCallAsync(request.ChannelId, request.Username));
});
// Store or update the current SDP offer for a channel call.
app.MapPost("/api/rtc/offer", async (RtcOffer request, RtcCallService rtcCallService) =>
{
await rtcCallService.WriteOfferAsync(request.ChannelId, request.Username, request.Sdp);
return Results.Ok();
});
// List all offers.
app.MapGet("/api/rtc/offers", async (RtcCallService rtcCallService) =>
{
return Results.Ok(await rtcCallService.GetOffersAsync());
});
// Return whether the specified channel currently has an active call.