Exemplo n.º 1
0
        /// <summary>
        /// Create service record resolving enumerator
        /// </summary>
        /// <param name="proxy">The proxy endpoint(s) to use</param>
        /// <param name="record">The service record to resolve</param>
        /// <param name="ct"></param>
        /// <returns></returns>
        public static async Task <IDnsServiceResolver> CreateServiceRecordResolverAsync(
            SocketAddress proxy, DnsServiceRecord record, bool cacheOnly, CancellationToken ct)
        {
            if (string.IsNullOrEmpty(record.Name) || string.IsNullOrEmpty(record.Type) ||
                record.Removed)
            {
                throw new ArgumentException("Invalid service, no name, not type or been removed",
                                            nameof(record));
            }
            var socket = new BrowseSocket(Socket.Provider, BrowseRequest.Service);
            await socket.ConnectAsync(proxy ?? record.Interface, ct);

            await socket.BrowseBeginAsync(record.ToSocketAddress(), ct);

            return(new ServiceRecordResolver(record)
            {
                Socket = socket, CacheOnly = cacheOnly
            });
        }
Exemplo n.º 2
0
 internal ServiceRecordResolver(DnsServiceRecord service)
 {
     _service = service;
 }
Exemplo n.º 3
0
 //
 // Resolve service record to a host name, port, plus txt records.
 //
 public static Task <IDnsServiceResolver> BrowseAsync(DnsServiceRecord record,
                                                      CancellationToken ct) =>
 BrowseAsync(record, false, ct);
Exemplo n.º 4
0
 //
 // Resolve service record to a host name, port, plus txt records.
 //
 public static Task <IDnsServiceResolver> BrowseAsync(DnsServiceRecord record,
                                                      bool cached, CancellationToken ct) =>
 BrowseAsync(null, record, cached, ct);
Exemplo n.º 5
0
 //
 // Resolve service record to a host name, port, plus txt records.
 //
 public static Task <IDnsServiceResolver> BrowseAsync(SocketAddress proxy, DnsServiceRecord record,
                                                      CancellationToken ct) =>
 BrowseAsync(proxy, record, false, ct);
Exemplo n.º 6
0
 /// <summary>
 /// Resolve service record to a host name, port, plus txt records.
 /// </summary>
 /// <param name="proxy"></param>
 /// <param name="service"></param>
 /// <param name="cached">Only return items until cache is exhausted</param>
 /// <param name="ct"></param>
 /// <returns></returns>
 public static Task <IDnsServiceResolver> BrowseAsync(SocketAddress proxy, DnsServiceRecord service,
                                                      bool cached, CancellationToken ct) =>
 BrowseClient.CreateServiceRecordResolverAsync(proxy, service, cached, ct);