Merge branch 'refs/heads/main' into Shared-Files

This commit is contained in:
2026-04-10 14:13:01 -04:00
7 changed files with 115 additions and 45 deletions

View File

@@ -1,4 +1,5 @@
using RelayServer.Models.Rtc;
using System.Text.Json;
using RelayServer.Models.Rtc;
using RelayServer.Services.Rtc;
namespace RelayServer.Endpoints;
@@ -86,7 +87,6 @@ public static class RtcEndpoints
request.Candidate.candidate,
request.Candidate.sdpMid,
request.Candidate.sdpMLineIndex
// request.Candidate.direction
);
RtcNotificationService.BroadcastToChannel(new RtcNotificationMessage
@@ -94,7 +94,7 @@ public static class RtcEndpoints
Type = "rtc_candidate_added",
ChannelId = request.ChannelId,
Username = request.Username,
/*Direction = request.Direction*/
Direction = JsonSerializer.Serialize(request.Candidate)
});
return Results.Ok();

View File

@@ -6,4 +6,12 @@ public sealed class RtcNotificationMessage
public required string ChannelId { get; set; }
public string? Username { get; set; }
public string? Direction { get; set; }
}
public sealed class RtcIceNotificationMessage
{
public required string Type { get; set; }
public required string ChannelId { get; set; }
public string? Username { get; set; }
public required IceCandidate Candidate { get; set; }
}

View File

@@ -25,4 +25,22 @@ public static class RtcNotificationService
host.Sessions.SendTo(json, sessionId);
}
}
public static void BroadcastToChannel(RtcIceNotificationMessage message)
{
if (Server is null)
return;
var host = Server.WebSocketServices["/"];
if (host is null)
return;
var json = JsonSerializer.Serialize(message);
var sessionIds = RtcChannelPresenceService.GetSessionsInChannel(message.ChannelId);
foreach (var sessionId in sessionIds)
{
host.Sessions.SendTo(json, sessionId);
}
}
}