diff --git a/RelayServer/Endpoints/RtcEndpoints.cs b/RelayServer/Endpoints/RtcEndpoints.cs index 04a1673..f3fcbb5 100644 --- a/RelayServer/Endpoints/RtcEndpoints.cs +++ b/RelayServer/Endpoints/RtcEndpoints.cs @@ -79,7 +79,7 @@ public static class RtcEndpoints }); // Store a new ICE candidate for the specified channel call. - app.MapPost("/api/rtc/candidate", async (DBIceCandidate request, RtcCallService rtcCallService) => + app.MapPost("/api/rtc/candidate", async (RtcIceCandidate request, RtcCallService rtcCallService) => { await rtcCallService.WriteIceCandidateAsync( request.ChannelId, diff --git a/RelayServer/Services/Rtc/RtcCallService.cs b/RelayServer/Services/Rtc/RtcCallService.cs index ba36048..ec3775f 100644 --- a/RelayServer/Services/Rtc/RtcCallService.cs +++ b/RelayServer/Services/Rtc/RtcCallService.cs @@ -21,13 +21,13 @@ public sealed class RtcCallService /// public async Task HasActiveCallAsync(string channelId) { - var activeCalls = await _db.Select("rtc_active_calls"); + var activeCalls = await _db.Select("rtc_active_calls"); return activeCalls.Any(x => x.ChannelId == channelId && x.IsActive); } - public async Task GetActiveCallAsync(string channelId) + public async Task GetActiveCallAsync(string channelId) { - var activeCalls = await _db.Select("rtc_active_calls"); + var activeCalls = await _db.Select("rtc_active_calls"); return activeCalls .Where(x => x.ChannelId == channelId && x.IsActive) .OrderByDescending(x => x.UpdatedAt) @@ -45,12 +45,12 @@ public sealed class RtcCallService /// The SDP offer payload. public async Task WriteOfferAsync(string channelId, string username, RtcSessionDescription sessionDescription) { - var activeCalls = await _db.Select("rtc_active_calls"); + var activeCalls = await _db.Select("rtc_active_calls"); var activeCall = activeCalls.FirstOrDefault(x => x.ChannelId == channelId && x.IsActive); if (activeCall is null) { - await _db.Create("rtc_active_calls", new RtcActiveCall + await _db.Create("rtc_active_calls", new DBActiveCall { ChannelId = channelId, OfferUser = username, @@ -76,7 +76,7 @@ public sealed class RtcCallService }; activeCall.UpdatedAt = DateTime.UtcNow; - await _db.Merge(activeCall); + await _db.Merge(activeCall); } /// @@ -101,7 +101,7 @@ public sealed class RtcCallService /// The SDP and type answer payload. public async Task WriteAnswerAsync(string channelId, RtcSessionDescription sessionDescription) { - var activeCalls = await _db.Select("rtc_active_calls"); + var activeCalls = await _db.Select("rtc_active_calls"); var activeCall = activeCalls.FirstOrDefault(x => x.ChannelId == channelId && x.IsActive); if (activeCall is null) @@ -114,7 +114,7 @@ public sealed class RtcCallService }; activeCall.UpdatedAt = DateTime.UtcNow; - await _db.Merge(activeCall); + await _db.Merge(activeCall); } /// @@ -166,7 +166,7 @@ public sealed class RtcCallService int? sdpMLineIndex/*, string direction*/) { - await _db.Create("rtc_ice_candidates", new RtcIceCandidate + await _db.Create("rtc_ice_candidates", new DBIceCandidate { ChannelId = channelId, Username = username, @@ -185,9 +185,9 @@ public sealed class RtcCallService /// /// A list of ICE candidates for the channel ordered from oldest to newest. /// - public async Task> GetIceCandidatesAsync(string channelId) + public async Task> GetIceCandidatesAsync(string channelId) { - var candidates = await _db.Select("rtc_ice_candidates"); + var candidates = await _db.Select("rtc_ice_candidates"); return candidates .Where(x => x.ChannelId == channelId) .OrderBy(x => x.CreatedAt) @@ -204,9 +204,9 @@ public sealed class RtcCallService /// /// A list of matching ICE candidates ordered from oldest to newest. /// - public async Task> GetIceCandidatesForOthersAsync(string channelId, string username, string direction) + public async Task> GetIceCandidatesForOthersAsync(string channelId, string username, string direction) { - var candidates = await _db.Select("rtc_ice_candidates"); + var candidates = await _db.Select("rtc_ice_candidates"); return candidates .Where(x => x.ChannelId == channelId && x.Username != username /*&& x.Direction == direction*/) .OrderBy(x => x.CreatedAt) @@ -221,7 +221,7 @@ public sealed class RtcCallService /// The user leaving the call. public async Task LeaveCallAsync(string channelId, string username) { - var activeCalls = await _db.Select("rtc_active_calls"); + var activeCalls = await _db.Select("rtc_active_calls"); var activeCall = activeCalls.FirstOrDefault(x => x.ChannelId == channelId && x.IsActive); if (activeCall is null) @@ -231,7 +231,7 @@ public sealed class RtcCallService { activeCall.IsActive = false; activeCall.UpdatedAt = DateTime.UtcNow; - await _db.Merge(activeCall); + await _db.Merge(activeCall); } } @@ -241,9 +241,9 @@ public sealed class RtcCallService /// /// A list of active calls with offers, ordered from newest to oldest. /// - public async Task> GetOffersAsync() + public async Task> GetOffersAsync() { - var activeCalls = await _db.Select("rtc_active_calls"); + var activeCalls = await _db.Select("rtc_active_calls"); return activeCalls .Where(x => x.Offer is not null) .OrderByDescending(x => x.UpdatedAt) diff --git a/RelayShared/Rtc/RtcModels.cs b/RelayShared/Rtc/RtcModels.cs index 5791275..1679bdd 100644 --- a/RelayShared/Rtc/RtcModels.cs +++ b/RelayShared/Rtc/RtcModels.cs @@ -121,7 +121,7 @@ public sealed class RtcAnswer public RtcSessionDescription SessionDescription { get; set; } = new(); } -public class RtcIceCandidate : Record //TODO: Swap names with DBIceCandidate. +public class DBIceCandidate : Record //TODO: Swap names with DBIceCandidate. { //TODO: Update all Record extensions to be DB*, all communication objects to be Rtc* public required string ChannelId { get; set; } public required string Username { get; set; } @@ -132,7 +132,7 @@ public class RtcIceCandidate : Record //TODO: Swap names with DBIceCandidate. public DateTime CreatedAt { get; set; } } -public class DBIceCandidate +public class RtcIceCandidate { public required string ChannelId { get; set; } public required string Username { get; set; } @@ -148,7 +148,7 @@ public class IceCandidate } -public sealed class RtcActiveCall : Record +public sealed class DBActiveCall : Record { public string ChannelId { get; set; } = string.Empty; public string? OfferUser { get; set; }