Beispiel #1
0
        /// <summary>
        ///   Gets the NATs.
        /// </summary>
        /// <returns>
        ///   A sequence of NAT clients that can be talked to,
        /// </returns>
        /// <remarks>
        ///   Asks each <see cref="GetGateways">gateways</see> if it supports
        ///   PCP or PMP.  If true, then a <see cref="NatClient"/> is retuned.
        /// </remarks>
        public static IEnumerable <NatClient> GetNats()
        {
            foreach (var gateway in GetGateways())
            {
                NatClient nat = new Pcp.Client(gateway);
                if (nat.IsAvailableAsync().Result)
                {
                    yield return(nat);

                    continue;
                }

                nat = new Pmp.Client(gateway);
                if (nat.IsAvailableAsync().Result)
                {
                    yield return(nat);

                    continue;
                }
            }
        }