예제 #1
0
        public async void CandiateBtn_Click(object sender, RoutedEventArgs e)
        {
            var m = new GetCandidateModel();

            m.uid = Uid;
            long.TryParse(fromUidTb.Text, out var fromUid);
            m.fromUid = fromUid;

            var candiate = await GetCandiate(m);

            if (candiate != "")
            {
                var candidates = JsonConvert.DeserializeObject <List <CandidateModel> >(candiate);
                if (fromUidTb.Text == "")
                {
                    foreach (var c in candidates)
                    {
                        await CurrentRoom.Pub.AddIceCandidate(new RTCIceCandidate
                        {
                            SdpMid        = c.sdpMid,
                            Candidate     = c.candidate,
                            SdpMLineIndex = (ushort)c.sdpMlineindex,
                        });
                    }
                }
                else
                {
                    if (fromUid == 0)
                    {
                        return;
                    }
                    if (!CurrentRoom.Recvs.ContainsKey(fromUid))
                    {
                        return;
                    }
                    foreach (var c in candidates)
                    {
                        await CurrentRoom.Recvs[fromUid].AddIceCandidate(new RTCIceCandidate
                        {
                            SdpMid        = c.sdpMid,
                            Candidate     = c.candidate,
                            SdpMLineIndex = (ushort)c.sdpMlineindex,
                        });
                    }
                }
            }
        }
예제 #2
0
 public async Task <string> GetCandiate(GetCandidateModel m)
 {
     return(await Http.PostAsnyc(m, "getCandidate"));
 }