added offers list to api
This commit is contained in:
@@ -24,6 +24,12 @@ public static class RtcEndpoints
|
||||
await rtcCallService.WriteOfferAsync(request.ChannelId, request.Username, request.Sdp);
|
||||
return Results.Ok();
|
||||
});
|
||||
// List all offers.
|
||||
app.MapGet("/api/rtc/offers", async (RtcCallService rtcCallService) =>
|
||||
{
|
||||
return Results.Ok(await rtcCallService.GetOffersAsync());
|
||||
|
||||
});
|
||||
|
||||
// Return whether the specified channel currently has an active call.
|
||||
app.MapGet("/api/rtc/active/{channelId}", async (string channelId, RtcCallService rtcCallService) =>
|
||||
@@ -32,7 +38,7 @@ public static class RtcEndpoints
|
||||
});
|
||||
|
||||
// Return the latest stored SDP offer for the specified channel.
|
||||
app.MapGet("/api/rtc/offer/{channelId}", async (string channelId, RtcCallService rtcCallService) =>
|
||||
app.MapGet("/api/rtc/offers/{channelId}", async (string channelId, RtcCallService rtcCallService) =>
|
||||
{
|
||||
var offer = await rtcCallService.GetOfferAsync(channelId);
|
||||
return offer is null ? Results.NotFound() : Results.Ok(offer);
|
||||
|
||||
@@ -279,4 +279,10 @@ public sealed class RtcCallService
|
||||
await _db.Merge<RtcActiveCall, RtcActiveCall>(activeCall);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<object?> GetOffersAsync()
|
||||
{
|
||||
var offers = await _db.Select<RtcOffer>("rtc_offers");
|
||||
return offers;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user