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 IStunIceServer stunIceServer) { try { stunIceServer = new StunIceServer(url); } catch (Exception) { stunIceServer = null; return false; } return true; }
public static bool TryCreate(Uri url, out IStunIceServer stunIceServer) { try { stunIceServer = new StunIceServer(url); } catch (Exception) { stunIceServer = null; return(false); } return(true); }