Renames complete.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -21,13 +21,13 @@ public sealed class RtcCallService
|
||||
/// </returns>
|
||||
public async Task<bool> HasActiveCallAsync(string channelId)
|
||||
{
|
||||
var activeCalls = await _db.Select<RtcActiveCall>("rtc_active_calls");
|
||||
var activeCalls = await _db.Select<DBActiveCall>("rtc_active_calls");
|
||||
return activeCalls.Any(x => x.ChannelId == channelId && x.IsActive);
|
||||
}
|
||||
|
||||
public async Task<RtcActiveCall?> GetActiveCallAsync(string channelId)
|
||||
public async Task<DBActiveCall?> GetActiveCallAsync(string channelId)
|
||||
{
|
||||
var activeCalls = await _db.Select<RtcActiveCall>("rtc_active_calls");
|
||||
var activeCalls = await _db.Select<DBActiveCall>("rtc_active_calls");
|
||||
return activeCalls
|
||||
.Where(x => x.ChannelId == channelId && x.IsActive)
|
||||
.OrderByDescending(x => x.UpdatedAt)
|
||||
@@ -45,12 +45,12 @@ public sealed class RtcCallService
|
||||
/// <param name="sdp">The SDP offer payload.</param>
|
||||
public async Task WriteOfferAsync(string channelId, string username, RtcSessionDescription sessionDescription)
|
||||
{
|
||||
var activeCalls = await _db.Select<RtcActiveCall>("rtc_active_calls");
|
||||
var activeCalls = await _db.Select<DBActiveCall>("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<RtcActiveCall, RtcActiveCall>(activeCall);
|
||||
await _db.Merge<DBActiveCall, DBActiveCall>(activeCall);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -101,7 +101,7 @@ public sealed class RtcCallService
|
||||
/// <param name="sessionDescription">The SDP and type answer payload.</param>
|
||||
public async Task WriteAnswerAsync(string channelId, RtcSessionDescription sessionDescription)
|
||||
{
|
||||
var activeCalls = await _db.Select<RtcActiveCall>("rtc_active_calls");
|
||||
var activeCalls = await _db.Select<DBActiveCall>("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<RtcActiveCall, RtcActiveCall>(activeCall);
|
||||
await _db.Merge<DBActiveCall, DBActiveCall>(activeCall);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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
|
||||
/// <returns>
|
||||
/// A list of ICE candidates for the channel ordered from oldest to newest.
|
||||
/// </returns>
|
||||
public async Task<List<RtcIceCandidate>> GetIceCandidatesAsync(string channelId)
|
||||
public async Task<List<DBIceCandidate>> GetIceCandidatesAsync(string channelId)
|
||||
{
|
||||
var candidates = await _db.Select<RtcIceCandidate>("rtc_ice_candidates");
|
||||
var candidates = await _db.Select<DBIceCandidate>("rtc_ice_candidates");
|
||||
return candidates
|
||||
.Where(x => x.ChannelId == channelId)
|
||||
.OrderBy(x => x.CreatedAt)
|
||||
@@ -204,9 +204,9 @@ public sealed class RtcCallService
|
||||
/// <returns>
|
||||
/// A list of matching ICE candidates ordered from oldest to newest.
|
||||
/// </returns>
|
||||
public async Task<List<RtcIceCandidate>> GetIceCandidatesForOthersAsync(string channelId, string username, string direction)
|
||||
public async Task<List<DBIceCandidate>> GetIceCandidatesForOthersAsync(string channelId, string username, string direction)
|
||||
{
|
||||
var candidates = await _db.Select<RtcIceCandidate>("rtc_ice_candidates");
|
||||
var candidates = await _db.Select<DBIceCandidate>("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
|
||||
/// <param name="username">The user leaving the call.</param>
|
||||
public async Task LeaveCallAsync(string channelId, string username)
|
||||
{
|
||||
var activeCalls = await _db.Select<RtcActiveCall>("rtc_active_calls");
|
||||
var activeCalls = await _db.Select<DBActiveCall>("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<RtcActiveCall, RtcActiveCall>(activeCall);
|
||||
await _db.Merge<DBActiveCall, DBActiveCall>(activeCall);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,9 +241,9 @@ public sealed class RtcCallService
|
||||
/// <returns>
|
||||
/// A list of active calls with offers, ordered from newest to oldest.
|
||||
/// </returns>
|
||||
public async Task<List<RtcActiveCall>> GetOffersAsync()
|
||||
public async Task<List<DBActiveCall>> GetOffersAsync()
|
||||
{
|
||||
var activeCalls = await _db.Select<RtcActiveCall>("rtc_active_calls");
|
||||
var activeCalls = await _db.Select<DBActiveCall>("rtc_active_calls");
|
||||
return activeCalls
|
||||
.Where(x => x.Offer is not null)
|
||||
.OrderByDescending(x => x.UpdatedAt)
|
||||
|
||||
@@ -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; }
|
||||
|
||||
Reference in New Issue
Block a user