public static ARDSignalingMessage MessageFromJSONString(string json) { var values = JsonConvert.DeserializeObject <Dictionary <string, string> >(json); ARDSignalingMessage message = new ARDSignalingMessage(); var type = values["type"]; if (type == "candidate") { RTCICECandidate candidate = new RTCICECandidate(values["id"], nint.Parse(values["label"]), values["candidate"]); message = new ARDICECandidateMessage(candidate); } else if (type == "offer" || type == "answer") { RTCSessionDescription description = new RTCSessionDescription(type, values["sdp"]); message = new ARDSessionDescriptionMessage(description); } else if (type == "bye") { message = new ARDByeMessage(); } else { System.Diagnostics.Debug.WriteLine($"Unexpected type: {type}"); } return(message); }
public static ARDSignalingMessage MessageFromJSONString(string json) { var values = JsonConvert.DeserializeObject <Dictionary <string, string> >(json); ARDSignalingMessage message = new ARDSignalingMessage(); var type = values["type"]; switch (type) { case "candidate": nint.TryParse(values["label"], out nint label); RTCICECandidate candidate = new RTCICECandidate(values["id"], label, values["candidate"]); message = new ARDICECandidateMessage(candidate); break; case "offer": case "answer": RTCSessionDescription description = new RTCSessionDescription(type, values["sdp"]); message = new ARDSessionDescriptionMessage(description); break; case "bye": message = new ARDByeMessage(); break; default: System.Diagnostics.Debug.WriteLine($"Unexpected type: {type}"); break; } return(message); }
public static string AsJSON(this RTCICECandidate rtcICEcandidate) { return(JsonConvert.SerializeObject( new { type = "candidate", id = rtcICEcandidate.SdpMid, label = (int)rtcICEcandidate.SdpMLineIndex, candidate = rtcICEcandidate.Sdp })); }
public static string AsJSON(this RTCICECandidate rtcICEcandidate) { dynamic jsonObject = new JObject(); try { jsonObject.type = "candidate"; jsonObject.id = (int)rtcICEcandidate.SdpMLineIndex; jsonObject.label = rtcICEcandidate.SdpMid; jsonObject.candidate = rtcICEcandidate.Sdp; } catch (Exception ex) { } return(JsonConvert.SerializeObject(jsonObject)); }
public ARDICECandidateMessage(RTCICECandidate candidate) { Type = ARDSignalingMessageType.Candidate; Candidate = candidate; }
public void PeerConnection(RTCPeerConnection peerConnection, RTCICECandidate candidate) { ARDICECandidateMessage message = new ARDICECandidateMessage(candidate); SendSignalingMessage(message).Wait(); }