Exemple #1
0
        public IObservable <IUdpIceCandidate> GetUdpIceCandidates()
        {
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                throw new InvalidOperationException("Cannot obtain the server reflexive UDP ICE candidate since the network interface has no network available.");
            }

            return(Observable.Merge(new IObservable <IUdpIceCandidate>[] { Observable.Return(FindLocalHostUdpIceCandidate()) }
                                    .Concat(IceServers.SelectMany(iceServer =>
            {
                IStunIceServer stunIceServer;
                if (StunIceServer.TryCreate(iceServer, out stunIceServer))
                {
                    return new[] { FindServerReflexiveUdpIceCandidate(stunIceServer).ToObservable() };
                }

                ITurnIceServer turnIceServer;
                if (TurnIceServer.TryCreate(iceServer, out turnIceServer))
                {
                    return new IObservable <IUdpIceCandidate>[]
                    {
                        FindServerReflexiveUdpIceCandidate(turnIceServer).ToObservable(),
                        FindRelayUdpIceCandidate(turnIceServer).ToObservable()
                    };
                }

                return Enumerable.Empty <IObservable <IUdpIceCandidate> >();
            }))));
        }
        public static bool TryCreate(Uri url, out ITurnIceServer turnIceServer)
        {
            try
            {
                turnIceServer = new TurnIceServer(url, null, null);
            }
            catch (Exception)
            {
                turnIceServer = null;
                return(false);
            }

            return(true);
        }
    public static bool TryCreate(Uri url, out ITurnIceServer turnIceServer)
    {
      try
      {
        turnIceServer = new TurnIceServer(url, null, null);
      }
      catch (Exception)
      {
        turnIceServer = null;
        return false;
      }

      return true;
    }