示例#1
0
        public async Task <string> SendOffer(GetAnswerModel m)
        {
            var answer = await Http.PostAsnyc(m, "getAnswer");

            foreach (var c in Candidates)
            {
                await SendCandidate(c);
            }
            return(answer);
        }
示例#2
0
        public async Task CreatOffer(long uid, long fromUid) //此时是发起方的操作
        {
            RTCSessionDescription offer;

            if (fromUid == 0)
            {
                offer = await CurrentRoom.Pub.CreateOffer();

                await CurrentRoom.Pub.SetLocalDescription(offer);
            }
            else
            {
                offer = await CurrentRoom.Recvs[fromUid].CreateOffer();
                await CurrentRoom.Recvs[fromUid].SetLocalDescription(offer);
            }


            var m = new GetAnswerModel();

            m.offer   = offer.Sdp;
            m.uid     = uid;
            m.fromUid = fromUid;
            var answerSdp = await SendOffer(m);

            if (answerSdp != "")
            {
                var answer = new RTCSessionDescription();
                answer.Type = RTCSdpType.Answer;
                answer.Sdp  = answerSdp;
                if (fromUid == 0)
                {
                    await CurrentRoom.Pub.SetRemoteDescription(answer);
                }
                else
                {
                    await CurrentRoom.Recvs[fromUid].SetRemoteDescription(answer);
                }
            }
        }