123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- using System.Text.Json;
- using System.Text.Json.Serialization;
- namespace VRTC
- {
- public class VrtcServerMessage
- {
- /// <summary>
- /// The commad from client
- /// </summary>
- [JsonPropertyName("command")]
- public VrtcCommands Command { get; set; }
- /// <summary>
- /// The rtc room ID
- /// </summary>
- [JsonPropertyName("roomId")]
- public uint RoomId { get; set; }
- /// <summary>
- /// The client ID
- /// </summary>
- [JsonPropertyName("clientId")]
- public string ClientId { get; set; }
- public string ToJson()
- {
- return JsonSerializer.Serialize(this);
- }
- }
- public class VrtcServerSdpMessage : VrtcServerMessage
- {
- /// <summary>
- /// The Web rtc protocol
- /// </summary>
- [JsonPropertyName("sdp")]
- public string Sdp { get; set; }
- public new string ToJson()
- {
- return JsonSerializer.Serialize(this);
- }
- }
- public class VrtcServerCandidateMessage : VrtcServerMessage
- {
- /// <summary>
- /// If present, this is the value of the "a=mid" attribute of the candidate's
- /// </summary>
- [JsonPropertyName("sdpMid")]
- public string SdpMid { get; set; }
- /// <summary>
- /// This indicates the index (starting at zero) of m= section this candidate is associated with. Needed when an endpoint doesn't support MIDs.
- /// </summary>
- [JsonPropertyName("sdpMLineIndex")]
- public int SdpMlineIndex { get; set; }
- /// <summary>
- /// The Web rtc protocol
- /// </summary>
- [JsonPropertyName("candidate")]
- public string Candidate { get; set; }
- public new string ToJson()
- {
- return JsonSerializer.Serialize(this);
- }
- [Test]
- public void ToJson_WhenCalled_ReturnsJsonString()
- {
- // Arrange
- var testObject = new TestObject();
- // Act
- var result = testObject.ToJson();
- // Assert
- Assert.IsNotNull(result);
- Assert.IsInstanceOfType(result, typeof(string));
- Assert.IsTrue(result.StartsWith("{"));
- Assert.IsTrue(result.EndsWith("}"));
- }
- }
- }
|