Пример #1
0
 private async Task InitializeWebRtc(Viewer viewer, CasterSocket casterSocket)
 {
     try
     {
         viewer.RtcSession = new WebRtcSession();
         viewer.RtcSession.LocalSdpReady += async(sender, sdp) =>
         {
             await casterSocket.SendRtcOfferToBrowser(sdp, viewer.ViewerConnectionID);
         };
         viewer.RtcSession.IceCandidateReady += async(sender, args) =>
         {
             await casterSocket.SendIceCandidateToBrowser(args.candidate, args.sdpMlineIndex, args.sdpMid, viewer.ViewerConnectionID);
         };
         await viewer.RtcSession.Init();
     }
     catch (Exception ex)
     {
         Logger.Write(ex);
     }
 }
Пример #2
0
        public async Task InitializeWebRtc()
        {
            try
            {
                var iceServers = await CasterSocket.GetIceServers();

                RtcSession = WebRtcSessionFactory.GetNewSession(this);
                RtcSession.LocalSdpReady += async(sender, sdp) =>
                {
                    await CasterSocket.SendRtcOfferToBrowser(sdp.Content, ViewerConnectionID, iceServers);
                };
                RtcSession.IceCandidateReady += async(sender, candidate) =>
                {
                    await CasterSocket.SendIceCandidateToBrowser(candidate.Content, candidate.SdpMlineIndex, candidate.SdpMid, ViewerConnectionID);
                };

                await RtcSession.Init(iceServers);
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
            }
        }