void OnAnswer(object sender, MessageEventArgs e) { var msg = e.Message; if (log.IsDebugEnabled) { log.Debug($"Answer from {e.RemoteEndPoint}"); } if (log.IsTraceEnabled) { log.Trace(msg); } // Any DNS-SD answers? var sd = msg.Answers .OfType <PTRRecord>() .Where(ptr => ptr.Name.IsSubdomainOf(LocalDomain)); foreach (var ptr in sd) { if (ptr.Name == ServiceName) { ServiceDiscovered?.Invoke(this, ptr.DomainName); } else if (ptr.TTL == TimeSpan.Zero) { var args = new ServiceInstanceShutdownEventArgs { ServiceInstanceName = ptr.DomainName, Message = msg }; ServiceInstanceShutdown?.Invoke(this, args); } else { var args = new ServiceInstanceDiscoveryEventArgs { ServiceInstanceName = ptr.DomainName, Message = msg }; ServiceInstanceDiscovered?.Invoke(this, args); } } }
void OnAnswer(object sender, MessageEventArgs e) { var msg = e.Message; // Any DNS-SD answers? var sd = msg.Answers.OfType <PTRRecord>(); foreach (var ptr in sd) { if (ptr.Name == ServiceName) { ServiceDiscovered?.Invoke(this, ptr.DomainName); } else { var args = new ServiceInstanceDiscoveryEventArgs { ServiceInstanceName = ptr.DomainName, Message = msg }; ServiceInstanceDiscovered?.Invoke(this, args); } } }