Fixed all underlying issues with the "Answer" call.
This commit is contained in:
@@ -49,15 +49,11 @@ public static class RtcEndpoints
|
||||
// Store a new SDP answer for the specified channel call.
|
||||
app.MapPost("/api/rtc/answer", async (RtcOffer request, RtcCallService rtcCallService) =>
|
||||
{
|
||||
Console.WriteLine($"RTC answer received for channel {request.ChannelId} from {request.Username}");
|
||||
|
||||
await rtcCallService.WriteAnswerAsync(request.ChannelId, request.SessionDescription);
|
||||
//DON'T FUCKING HARDCODE STRINGS INTO API REQUESTS
|
||||
// await rtcCallService.WriteAnswerAsync(
|
||||
// request.ChannelId,
|
||||
// new RtcSessionDescription
|
||||
// {
|
||||
// Type = "answer",
|
||||
// Sdp = request.Sdp
|
||||
// });
|
||||
|
||||
Console.WriteLine($"Broadcasting rtc_answer_updated for {request.ChannelId}");
|
||||
|
||||
RtcNotificationService.BroadcastToChannel(new RtcNotificationMessage
|
||||
{
|
||||
|
||||
@@ -124,13 +124,14 @@ public sealed class RtcCallService
|
||||
/// <returns>
|
||||
/// A list of answers for the channel ordered from oldest to newest.
|
||||
/// </returns>
|
||||
public async Task<List<RtcAnswer>> GetAnswersAsync(string channelId)
|
||||
public async Task<List<RtcSessionDescription>> GetAnswersAsync(string channelId)
|
||||
{
|
||||
var answers = await _db.Select<RtcAnswer>("rtc_answers");
|
||||
return answers
|
||||
.Where(x => x.ChannelId == channelId)
|
||||
.OrderBy(x => x.CreatedAt)
|
||||
.ToList();
|
||||
var activeCall = await GetActiveCallAsync(channelId);
|
||||
|
||||
if (activeCall?.Answer is null)
|
||||
return [];
|
||||
|
||||
return [activeCall.Answer];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -140,13 +141,10 @@ public sealed class RtcCallService
|
||||
/// <returns>
|
||||
/// The newest answer for the channel, or null if no answer exists.
|
||||
/// </returns>
|
||||
public async Task<RtcAnswer?> GetLatestAnswerAsync(string channelId)
|
||||
public async Task<RtcSessionDescription?> GetLatestAnswerAsync(string channelId)
|
||||
{
|
||||
var answers = await _db.Select<RtcAnswer>("rtc_answers");
|
||||
return answers
|
||||
.Where(x => x.ChannelId == channelId)
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.FirstOrDefault();
|
||||
var activeCall = await GetActiveCallAsync(channelId);
|
||||
return activeCall?.Answer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user