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.
|
// 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(
|
await rtcCallService.WriteIceCandidateAsync(
|
||||||
request.ChannelId,
|
request.ChannelId,
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ public sealed class RtcCallService
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public async Task<bool> HasActiveCallAsync(string channelId)
|
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);
|
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
|
return activeCalls
|
||||||
.Where(x => x.ChannelId == channelId && x.IsActive)
|
.Where(x => x.ChannelId == channelId && x.IsActive)
|
||||||
.OrderByDescending(x => x.UpdatedAt)
|
.OrderByDescending(x => x.UpdatedAt)
|
||||||
@@ -45,12 +45,12 @@ public sealed class RtcCallService
|
|||||||
/// <param name="sdp">The SDP offer payload.</param>
|
/// <param name="sdp">The SDP offer payload.</param>
|
||||||
public async Task WriteOfferAsync(string channelId, string username, RtcSessionDescription sessionDescription)
|
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);
|
var activeCall = activeCalls.FirstOrDefault(x => x.ChannelId == channelId && x.IsActive);
|
||||||
|
|
||||||
if (activeCall is null)
|
if (activeCall is null)
|
||||||
{
|
{
|
||||||
await _db.Create("rtc_active_calls", new RtcActiveCall
|
await _db.Create("rtc_active_calls", new DBActiveCall
|
||||||
{
|
{
|
||||||
ChannelId = channelId,
|
ChannelId = channelId,
|
||||||
OfferUser = username,
|
OfferUser = username,
|
||||||
@@ -76,7 +76,7 @@ public sealed class RtcCallService
|
|||||||
};
|
};
|
||||||
activeCall.UpdatedAt = DateTime.UtcNow;
|
activeCall.UpdatedAt = DateTime.UtcNow;
|
||||||
|
|
||||||
await _db.Merge<RtcActiveCall, RtcActiveCall>(activeCall);
|
await _db.Merge<DBActiveCall, DBActiveCall>(activeCall);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -101,7 +101,7 @@ public sealed class RtcCallService
|
|||||||
/// <param name="sessionDescription">The SDP and type answer payload.</param>
|
/// <param name="sessionDescription">The SDP and type answer payload.</param>
|
||||||
public async Task WriteAnswerAsync(string channelId, RtcSessionDescription sessionDescription)
|
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);
|
var activeCall = activeCalls.FirstOrDefault(x => x.ChannelId == channelId && x.IsActive);
|
||||||
|
|
||||||
if (activeCall is null)
|
if (activeCall is null)
|
||||||
@@ -114,7 +114,7 @@ public sealed class RtcCallService
|
|||||||
};
|
};
|
||||||
activeCall.UpdatedAt = DateTime.UtcNow;
|
activeCall.UpdatedAt = DateTime.UtcNow;
|
||||||
|
|
||||||
await _db.Merge<RtcActiveCall, RtcActiveCall>(activeCall);
|
await _db.Merge<DBActiveCall, DBActiveCall>(activeCall);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -166,7 +166,7 @@ public sealed class RtcCallService
|
|||||||
int? sdpMLineIndex/*,
|
int? sdpMLineIndex/*,
|
||||||
string direction*/)
|
string direction*/)
|
||||||
{
|
{
|
||||||
await _db.Create("rtc_ice_candidates", new RtcIceCandidate
|
await _db.Create("rtc_ice_candidates", new DBIceCandidate
|
||||||
{
|
{
|
||||||
ChannelId = channelId,
|
ChannelId = channelId,
|
||||||
Username = username,
|
Username = username,
|
||||||
@@ -185,9 +185,9 @@ public sealed class RtcCallService
|
|||||||
/// <returns>
|
/// <returns>
|
||||||
/// A list of ICE candidates for the channel ordered from oldest to newest.
|
/// A list of ICE candidates for the channel ordered from oldest to newest.
|
||||||
/// </returns>
|
/// </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
|
return candidates
|
||||||
.Where(x => x.ChannelId == channelId)
|
.Where(x => x.ChannelId == channelId)
|
||||||
.OrderBy(x => x.CreatedAt)
|
.OrderBy(x => x.CreatedAt)
|
||||||
@@ -204,9 +204,9 @@ public sealed class RtcCallService
|
|||||||
/// <returns>
|
/// <returns>
|
||||||
/// A list of matching ICE candidates ordered from oldest to newest.
|
/// A list of matching ICE candidates ordered from oldest to newest.
|
||||||
/// </returns>
|
/// </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
|
return candidates
|
||||||
.Where(x => x.ChannelId == channelId && x.Username != username /*&& x.Direction == direction*/)
|
.Where(x => x.ChannelId == channelId && x.Username != username /*&& x.Direction == direction*/)
|
||||||
.OrderBy(x => x.CreatedAt)
|
.OrderBy(x => x.CreatedAt)
|
||||||
@@ -221,7 +221,7 @@ public sealed class RtcCallService
|
|||||||
/// <param name="username">The user leaving the call.</param>
|
/// <param name="username">The user leaving the call.</param>
|
||||||
public async Task LeaveCallAsync(string channelId, string username)
|
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);
|
var activeCall = activeCalls.FirstOrDefault(x => x.ChannelId == channelId && x.IsActive);
|
||||||
|
|
||||||
if (activeCall is null)
|
if (activeCall is null)
|
||||||
@@ -231,7 +231,7 @@ public sealed class RtcCallService
|
|||||||
{
|
{
|
||||||
activeCall.IsActive = false;
|
activeCall.IsActive = false;
|
||||||
activeCall.UpdatedAt = DateTime.UtcNow;
|
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>
|
/// <returns>
|
||||||
/// A list of active calls with offers, ordered from newest to oldest.
|
/// A list of active calls with offers, ordered from newest to oldest.
|
||||||
/// </returns>
|
/// </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
|
return activeCalls
|
||||||
.Where(x => x.Offer is not null)
|
.Where(x => x.Offer is not null)
|
||||||
.OrderByDescending(x => x.UpdatedAt)
|
.OrderByDescending(x => x.UpdatedAt)
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public sealed class RtcAnswer
|
|||||||
public RtcSessionDescription SessionDescription { get; set; } = new();
|
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*
|
{ //TODO: Update all Record extensions to be DB*, all communication objects to be Rtc*
|
||||||
public required string ChannelId { get; set; }
|
public required string ChannelId { get; set; }
|
||||||
public required string Username { 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 DateTime CreatedAt { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DBIceCandidate
|
public class RtcIceCandidate
|
||||||
{
|
{
|
||||||
public required string ChannelId { get; set; }
|
public required string ChannelId { get; set; }
|
||||||
public required string Username { 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 ChannelId { get; set; } = string.Empty;
|
||||||
public string? OfferUser { get; set; }
|
public string? OfferUser { get; set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user