155 lines
4.9 KiB
C#
155 lines
4.9 KiB
C#
using SurrealDb.Net.Models;
|
|
|
|
namespace RelayShared.Rtc;
|
|
|
|
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 sealed class RtcSignalMessage
|
|
{
|
|
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 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
|
|
{
|
|
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; }
|
|
} |