using SurrealDb.Net.Models; namespace RelayShared.Rtc; public enum SignalType { Offer, Answer, Candidate, OfferUpdated, AnswerUpdated, CandidateAdded, CallLeft, ChannelList, ServerPublicKey, EncryptedSignal, EncryptedChat, ClientEncryptedChat } public sealed class RtcSignalMessage { public SignalType Type { get; set; } 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 SignalType? Type { get; set; } public string? ChannelId { get; set; } public string? Username { get; set; } public string? Direction { get; set; } } public sealed class ServerPublicKeyMessage { public SignalType Type { get; set; } = SignalType.ServerPublicKey; public string PublicKey { get; set; } = string.Empty; } public sealed class SocketRtcSignalMessage { public SignalType Type { get; set; } 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 SignalType Type { get; set; } = SignalType.EncryptedChat; 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 SignalType Type { get; set; } = SignalType.ChannelList; public List 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 string Type { get; set; } = string.Empty; public string Sdp { get; set; } = string.Empty; } public sealed class RtcOffer { public string ChannelId { get; set; } = string.Empty; public string Username { get; set; } = string.Empty; public RtcSessionDescription SessionDescription { get; set; } = new(); } public sealed class RtcAnswer { public string ChannelId { get; set; } = string.Empty; public string Username { get; set; } = string.Empty; public RtcSessionDescription SessionDescription { get; set; } = new(); } public class RtcIceCandidate : Record //TODO: Swap names with DBIceCandidate. { //TODO: Update all Record extensions to be DB*, all communication objects to be Rtc* public required string ChannelId { get; set; } public required string Username { get; set; } public required string Candidate { get; set; } public string? SdpMid { get; set; } public int? SdpMLineIndex { get; set; } // public required string Direction { get; set; } // "offer" or "answer" public DateTime CreatedAt { get; set; } } public class DBIceCandidate { public required string ChannelId { get; set; } public required string Username { get; set; } public required IceCandidate Candidate { get; set; } } public class IceCandidate { public required string candidate { get; set; } public required string sdpMid { get; set; } public required int sdpMLineIndex { get; set; } public required string usernameFragment { get; set; } } public sealed class RtcActiveCall : Record { public string ChannelId { get; set; } = string.Empty; public string? OfferUser { get; set; } public RtcSessionDescription? Offer { get; set; } public RtcSessionDescription? Answer { get; set; } public DateTime CreatedAt { get; set; } public DateTime UpdatedAt { get; set; } public bool IsActive { get; set; } }