Shared System completed. Test for bugs.

This commit is contained in:
2026-04-10 14:14:35 -04:00
parent e855948ca9
commit c3b8dc5061
31 changed files with 109 additions and 282 deletions

View File

@@ -2,51 +2,118 @@
namespace RelayShared.Rtc;
public class RtcSignalTypes
public static class RtcSignalTypes
{
public const string Offer = "rtc_offer";
public const string Answer = "rtc_answer";
public const string Candidate = "rtc_candidate";
public const string OfferUpdated = "rtc_offer_updated";
public const string AnswerUpdated = "rtc_answer_updated";
public const string CandidateAdded = "rtc_candidate_added";
public const string CallLeft = "rtc_call_left";
}
public class RtcJoinRequest
public sealed class RtcSignalMessage
{
public required string ChannelId { get; set; }
public required string Username { get; set; }
public string Type { get; set; } = string.Empty;
public string From { get; set; } = string.Empty;
public string ChannelId { get; set; } = string.Empty;
public string? Sdp { get; set; }
public string? Candidate { get; set; }
public string? SdpMid { get; set; }
public int? SdpMLineIndex { get; set; }
public bool IsInitiator { get; set; }
}
public sealed class RtcNotificationMessage
{
public string? Type { get; set; }
public string? ChannelId { get; set; }
public string? Username { get; set; }
public string? Direction { get; set; }
}
public sealed class ServerPublicKeyMessage
{
public string Type { get; set; } = string.Empty;
public string PublicKey { get; set; } = string.Empty;
}
public sealed class SocketRtcSignalMessage
{
public string Type { get; set; } = string.Empty;
public string SenderUsername { get; set; } = string.Empty;
public string ChannelId { get; set; } = string.Empty;
public string CipherText { get; set; } = string.Empty;
public string Nonce { get; set; } = string.Empty;
public string Tag { get; set; } = string.Empty;
public string EncryptedKey { get; set; } = string.Empty;
}
public sealed class SocketEncryptedMessage
{
public string Type { get; set; } = string.Empty;
public string SenderUsername { get; set; } = string.Empty;
public string RecipientUsername { get; set; } = string.Empty;
public string ChannelId { get; set; } = string.Empty;
public string CipherText { get; set; } = string.Empty;
public string Nonce { get; set; } = string.Empty;
public string Tag { get; set; } = string.Empty;
public string EncryptedKey { get; set; } = string.Empty;
}
public sealed class ChannelItem
{
public string ChannelId { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public DateTime CreatedAt { get; set; }
}
public sealed class SocketChannelList
{
public string Type { get; set; } = string.Empty;
public List<ChannelItem> Channels { get; set; } = [];
}
public sealed class RtcJoinRequest
{
public string ChannelId { get; set; } = string.Empty;
public string Username { get; set; } = string.Empty;
}
public sealed class RtcJoinResponse
{
public string ChannelId { get; set; } = string.Empty;
public bool HasActiveCall { get; set; }
public bool IsOfferer { get; set; }
public string? OfferUser { get; set; }
public RtcSessionDescription? OfferSdp { get; set; }
}
public sealed class RtcLeaveRequest
{
public string ChannelId { get; set; } = string.Empty;
public string Username { get; set; } = string.Empty;
}
public sealed class RtcSessionDescription
{
public required string Type { get; set; }
public required string Sdp { get; set; }
public string Type { get; set; } = string.Empty;
public string Sdp { get; set; } = string.Empty;
}
public class RtcOffer : Record
public sealed class RtcOffer
{
public required string ChannelId { get; set; }
public required string Username { get; set; }
public required RtcSessionDescription SessionDescription { get; set; }
// public required string Type { get; set; }
// public required string Sdp { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
public string ChannelId { get; set; } = string.Empty;
public string Username { get; set; } = string.Empty;
public RtcSessionDescription SessionDescription { get; set; } = new();
}
public class RtcLeaveRequest
public sealed class RtcAnswer
{
public required string ChannelId { get; set; }
public required string Username { get; set; }
}
public class RtcJoinResponse
{
public required string ChannelId { get; set; }
public bool HasActiveCall { get; set; }
public bool IsOfferer { get; set; }
public string? OfferUser { get; set; }
public string? OfferSdp { get; set; }
public string ChannelId { get; set; } = string.Empty;
public string Username { get; set; } = string.Empty;
public RtcSessionDescription SessionDescription { get; set; } = new();
}
public class RtcIceCandidate : Record
@@ -76,18 +143,9 @@ public class IceCandidate
}
public class RtcAnswer : Record
{
public required string ChannelId { get; set; }
public required string OfferUser { get; set; }
public required string AnswerUser { get; set; }
public required string Sdp { get; set; }
public DateTime CreatedAt { get; set; }
}
public sealed class RtcActiveCall : Record
{
public required string ChannelId { get; set; }
public string ChannelId { get; set; } = string.Empty;
public string? OfferUser { get; set; }
public RtcSessionDescription? Offer { get; set; }
public RtcSessionDescription? Answer { get; set; }