Update: Needs Testing - Not Tested

This commit is contained in:
2026-04-04 16:17:57 -04:00
parent c89a0cf88b
commit 3f27c94032
4 changed files with 70 additions and 11 deletions

View File

@@ -16,6 +16,14 @@ public static class RtcEndpoints
app.MapPost("/api/rtc/offer", async (RtcOffer request, RtcCallService rtcCallService) =>
{
await rtcCallService.WriteOfferAsync(request.ChannelId, request.Username, request.SessionDescription);
RtcNotificationService.Broadcast(new RtcNotificationMessage
{
Type = "rtc_offer_updated",
ChannelId = request.ChannelId,
Username = request.Username
});
return Results.Ok();
});
@@ -31,14 +39,6 @@ public static class RtcEndpoints
return Results.Ok(await rtcCallService.HasActiveCallAsync(channelId));
});
// TODO: You can uncomment me if you'd like to have both. Otherwise delete me - you never know but I made it "call" instead of "active"
// Return the active call object for the specified channel.
//app.MapGet("/api/rtc/call/{channelId}", async (string channelId, RtcCallService rtcCallService) =>
//{
// var call = await rtcCallService.GetActiveCallAsync(channelId);
// return call is null ? Results.NotFound() : Results.Ok(call);
//});
// Return the latest stored SDP offer for the specified channel.
app.MapGet("/api/rtc/offers/{channelId}", async (string channelId, RtcCallService rtcCallService) =>
{
@@ -47,9 +47,22 @@ public static class RtcEndpoints
});
// Store a new SDP answer for the specified channel call.
app.MapPost("/api/rtc/answer", async (RtcOffer request, RtcCallService rtcCallService) =>
app.MapPost("/api/rtc/answer", async (RtcAnswer request, RtcCallService rtcCallService) =>
{
await rtcCallService.WriteAnswerAsync(request.ChannelId, request.SessionDescription);
await rtcCallService.WriteAnswerAsync(
request.ChannelId,
new RtcSessionDescription
{
Type = "answer",
Sdp = request.Sdp
});
RtcNotificationService.Broadcast(new RtcNotificationMessage
{
Type = "rtc_answer_updated",
ChannelId = request.ChannelId
});
return Results.Ok();
});
@@ -78,6 +91,14 @@ public static class RtcEndpoints
request.Direction
);
RtcNotificationService.Broadcast(new RtcNotificationMessage
{
Type = "rtc_candidate_added",
ChannelId = request.ChannelId,
Username = request.Username,
Direction = request.Direction
});
return Results.Ok();
});
@@ -102,6 +123,14 @@ public static class RtcEndpoints
app.MapPost("/api/rtc/leave", async (RtcLeaveRequest request, RtcCallService rtcCallService) =>
{
await rtcCallService.LeaveCallAsync(request.ChannelId, request.Username);
RtcNotificationService.Broadcast(new RtcNotificationMessage
{
Type = "rtc_call_left",
ChannelId = request.ChannelId,
Username = request.Username
});
return Results.Ok();
});
}