updated RtcOffer to reflect proper communication needs and added todo
This commit is contained in:
@@ -15,7 +15,7 @@ public static class RtcEndpoints
|
||||
// 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);
|
||||
await rtcCallService.WriteOfferAsync(request.ChannelId, request.Username, request.SessionDescription);
|
||||
return Results.Ok();
|
||||
});
|
||||
|
||||
@@ -29,7 +29,7 @@ public static class RtcEndpoints
|
||||
app.MapGet("/api/rtc/active/{channelId}", async (string channelId, RtcCallService rtcCallService) =>
|
||||
{
|
||||
var call = await rtcCallService.GetActiveCallAsync(channelId);
|
||||
return call is null ? Results.NotFound() : Results.Ok(call);
|
||||
return call is null ? Results.NotFound() : Results.Ok(call); //TODO: needs to return a true or false value if the channelId is active
|
||||
});
|
||||
|
||||
// Return the latest stored SDP offer for the specified channel.
|
||||
|
||||
@@ -6,7 +6,9 @@ public class RtcOffer : Record
|
||||
{
|
||||
public required string ChannelId { get; set; }
|
||||
public required string Username { get; set; }
|
||||
public required string Sdp { get; set; }
|
||||
public required RtcSessionDescription SessionDescription { get; set; }
|
||||
// public required string Type { get; set; }
|
||||
// public required string Sdp { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
}
|
||||
@@ -41,8 +41,9 @@ public sealed class RtcCallService
|
||||
/// </summary>
|
||||
/// <param name="channelId">The channel the offer belongs to.</param>
|
||||
/// <param name="username">The user creating the offer.</param>
|
||||
/// <param name="type">The RtcSession Type. </param>
|
||||
/// <param name="sdp">The SDP offer payload.</param>
|
||||
public async Task WriteOfferAsync(string channelId, string username, string sdp)
|
||||
public async Task WriteOfferAsync(string channelId, string username, RtcSessionDescription sessionDescription)
|
||||
{
|
||||
var activeCalls = await _db.Select<RtcActiveCall>("rtc_active_calls");
|
||||
var activeCall = activeCalls.FirstOrDefault(x => x.ChannelId == channelId && x.IsActive);
|
||||
@@ -55,8 +56,8 @@ public sealed class RtcCallService
|
||||
OfferUser = username,
|
||||
Offer = new RtcSessionDescription
|
||||
{
|
||||
Type = "offer",
|
||||
Sdp = sdp
|
||||
Type = sessionDescription.Type,
|
||||
Sdp = sessionDescription.Sdp
|
||||
},
|
||||
Answer = null,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
@@ -70,8 +71,8 @@ public sealed class RtcCallService
|
||||
activeCall.OfferUser = username;
|
||||
activeCall.Offer = new RtcSessionDescription
|
||||
{
|
||||
Type = "offer",
|
||||
Sdp = sdp
|
||||
Type = sessionDescription.Type,
|
||||
Sdp = sessionDescription.Sdp
|
||||
};
|
||||
activeCall.UpdatedAt = DateTime.UtcNow;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user