Messaging works, let's start there.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using SurrealDb.Net.Models;
|
||||
using System.Text.Json.Serialization;
|
||||
using SurrealDb.Net.Models;
|
||||
|
||||
namespace RelayShared.Rtc;
|
||||
|
||||
[JsonConverter(typeof(JsonStringEnumConverter<SignalType>))]
|
||||
public enum SignalType
|
||||
{
|
||||
Offer,
|
||||
@@ -20,141 +22,276 @@ public enum SignalType
|
||||
|
||||
public sealed class RtcSignalMessage
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public SignalType Type { get; set; }
|
||||
|
||||
[JsonPropertyName("from")]
|
||||
public string From { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("channelId")]
|
||||
public string ChannelId { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("sdp")]
|
||||
public string? Sdp { get; set; }
|
||||
|
||||
[JsonPropertyName("candidate")]
|
||||
public string? Candidate { get; set; }
|
||||
|
||||
[JsonPropertyName("sdpMid")]
|
||||
public string? SdpMid { get; set; }
|
||||
|
||||
[JsonPropertyName("sdpMLineIndex")]
|
||||
public int? SdpMLineIndex { get; set; }
|
||||
|
||||
[JsonPropertyName("isInitiator")]
|
||||
public bool IsInitiator { get; set; }
|
||||
}
|
||||
|
||||
public sealed class RtcNotificationMessage
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public SignalType? Type { get; set; }
|
||||
|
||||
[JsonPropertyName("channelId")]
|
||||
public string? ChannelId { get; set; }
|
||||
|
||||
[JsonPropertyName("username")]
|
||||
public string? Username { get; set; }
|
||||
|
||||
[JsonPropertyName("targetUsername")]
|
||||
public string? TargetUsername { get; set; }
|
||||
|
||||
[JsonPropertyName("direction")]
|
||||
public string? Direction { get; set; }
|
||||
}
|
||||
|
||||
public sealed class ServerPublicKeyMessage
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public SignalType Type { get; set; } = SignalType.ServerPublicKey;
|
||||
|
||||
[JsonPropertyName("publicKey")]
|
||||
public string PublicKey { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public sealed class SocketRtcSignalMessage
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public SignalType Type { get; set; }
|
||||
|
||||
[JsonPropertyName("senderUsername")]
|
||||
public string SenderUsername { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("channelId")]
|
||||
public string ChannelId { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("cipherText")]
|
||||
public string CipherText { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("nonce")]
|
||||
public string Nonce { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("tag")]
|
||||
public string Tag { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("encryptedKey")]
|
||||
public string EncryptedKey { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public sealed class SocketEncryptedMessage
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public SignalType Type { get; set; } = SignalType.EncryptedChat;
|
||||
|
||||
[JsonPropertyName("senderUsername")]
|
||||
public string SenderUsername { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("recipientUsername")]
|
||||
public string RecipientUsername { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("channelId")]
|
||||
public string ChannelId { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("cipherText")]
|
||||
public string CipherText { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("nonce")]
|
||||
public string Nonce { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("tag")]
|
||||
public string Tag { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("encryptedKey")]
|
||||
public string EncryptedKey { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public sealed class ChannelItem
|
||||
{
|
||||
[JsonPropertyName("channelId")]
|
||||
public string ChannelId { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("createdAt")]
|
||||
public DateTime CreatedAt { get; set; }
|
||||
}
|
||||
|
||||
public sealed class SocketChannelList
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public SignalType Type { get; set; } = SignalType.ChannelList;
|
||||
|
||||
[JsonPropertyName("channels")]
|
||||
public List<ChannelItem> Channels { get; set; } = [];
|
||||
}
|
||||
|
||||
public sealed class RtcJoinRequest
|
||||
{
|
||||
[JsonPropertyName("channelId")]
|
||||
public string ChannelId { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("username")]
|
||||
public string Username { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public sealed class RtcJoinResponse
|
||||
{
|
||||
[JsonPropertyName("channelId")]
|
||||
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; }
|
||||
|
||||
[JsonPropertyName("participants")]
|
||||
public List<string> Participants { get; set; } = [];
|
||||
}
|
||||
|
||||
public sealed class RtcLeaveRequest
|
||||
{
|
||||
[JsonPropertyName("channelId")]
|
||||
public string ChannelId { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("username")]
|
||||
public string Username { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public sealed class RtcSessionDescription
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public SignalType Type { get; set; }
|
||||
|
||||
[JsonPropertyName("sdp")]
|
||||
public string Sdp { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public sealed class RtcOffer
|
||||
{
|
||||
[JsonPropertyName("channelId")]
|
||||
public string ChannelId { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("username")]
|
||||
public string Username { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("targetUsername")]
|
||||
public string TargetUsername { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("sessionDescription")]
|
||||
public RtcSessionDescription SessionDescription { get; set; } = new();
|
||||
}
|
||||
|
||||
public sealed class RtcAnswer
|
||||
{
|
||||
[JsonPropertyName("channelId")]
|
||||
public string ChannelId { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("username")]
|
||||
public string Username { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("targetUsername")]
|
||||
public string TargetUsername { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("sessionDescription")]
|
||||
public RtcSessionDescription SessionDescription { get; set; } = new();
|
||||
}
|
||||
|
||||
public sealed class RtcParticipantState
|
||||
{
|
||||
[JsonPropertyName("username")]
|
||||
public string Username { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("offer")]
|
||||
public RtcSessionDescription? Offer { get; set; }
|
||||
|
||||
[JsonPropertyName("answer")]
|
||||
public RtcSessionDescription? Answer { get; set; }
|
||||
}
|
||||
|
||||
public class RtcIceCandidate : Record
|
||||
{
|
||||
[JsonPropertyName("channelId")]
|
||||
public required string ChannelId { get; set; }
|
||||
|
||||
[JsonPropertyName("username")]
|
||||
public required string Username { get; set; }
|
||||
|
||||
[JsonPropertyName("targetUsername")]
|
||||
public required string TargetUsername { get; set; }
|
||||
|
||||
[JsonPropertyName("candidate")]
|
||||
public required string Candidate { get; set; }
|
||||
|
||||
[JsonPropertyName("sdpMid")]
|
||||
public string? SdpMid { get; set; }
|
||||
|
||||
[JsonPropertyName("sdpMLineIndex")]
|
||||
public int? SdpMLineIndex { get; set; }
|
||||
// public required string Direction { get; set; } // "offer" or "answer"
|
||||
|
||||
[JsonPropertyName("createdAt")]
|
||||
public DateTime CreatedAt { get; set; }
|
||||
}
|
||||
|
||||
public class DBIceCandidate
|
||||
{
|
||||
[JsonPropertyName("channelId")]
|
||||
public required string ChannelId { get; set; }
|
||||
|
||||
[JsonPropertyName("username")]
|
||||
public required string Username { get; set; }
|
||||
|
||||
[JsonPropertyName("targetUsername")]
|
||||
public required string TargetUsername { get; set; }
|
||||
|
||||
[JsonPropertyName("candidate")]
|
||||
public required IceCandidate Candidate { get; set; }
|
||||
}
|
||||
|
||||
public class IceCandidate
|
||||
{
|
||||
[JsonPropertyName("candidate")]
|
||||
public required string candidate { get; set; }
|
||||
|
||||
[JsonPropertyName("sdpMid")]
|
||||
public required string sdpMid { get; set; }
|
||||
|
||||
[JsonPropertyName("sdpMLineIndex")]
|
||||
public required int sdpMLineIndex { get; set; }
|
||||
|
||||
[JsonPropertyName("usernameFragment")]
|
||||
public required string usernameFragment { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public sealed class RtcActiveCall : Record
|
||||
{
|
||||
[JsonPropertyName("channelId")]
|
||||
public string ChannelId { get; set; } = string.Empty;
|
||||
public string? OfferUser { get; set; }
|
||||
public RtcSessionDescription? Offer { get; set; }
|
||||
public RtcSessionDescription? Answer { get; set; }
|
||||
|
||||
[JsonPropertyName("participants")]
|
||||
public List<RtcParticipantState> Participants { get; set; } = [];
|
||||
|
||||
[JsonPropertyName("createdAt")]
|
||||
public DateTime CreatedAt { get; set; }
|
||||
|
||||
[JsonPropertyName("updatedAt")]
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
|
||||
[JsonPropertyName("isActive")]
|
||||
public bool IsActive { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user