Fixed all underlying issues with the "Answer" call.

This commit is contained in:
2026-04-06 16:08:37 -04:00
parent aa7f6597c4
commit 7d8755ca71
6 changed files with 134 additions and 38 deletions

View File

@@ -45,9 +45,14 @@ public class ServerAPI
return offer;
}
public static async Task<Uri> PostAnswerAsync(DBOffer answer)
public static async Task<Uri?> PostAnswerAsync(DBOffer answer)
{
HttpResponseMessage response = await client.PostAsJsonAsync("api/rtc/answer", answer);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine("PostAnswerAsync status: " + response.StatusCode);
Console.WriteLine("PostAnswerAsync body: " + body);
response.EnsureSuccessStatusCode();
return response.Headers.Location;
}
@@ -94,6 +99,18 @@ public class ServerAPI
return response.Headers.Location;
}
public static async Task<RtcDescription?> GetAnswerForChannelAsync(string? channelId)
{
if (string.IsNullOrWhiteSpace(channelId))
return null;
HttpResponseMessage response = await client.GetAsync($"api/rtc/answer/{channelId}");
if (!response.IsSuccessStatusCode)
return null;
var json = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<RtcDescription>(json);
}
}
public class RtcDescription