     /// - Parameters:
     ///   - domain: error domain
     ///   - error: error code
-    func cancel(domain: String = DNSSDNetService.netServiceErrorDomain, error: Any = DNSSDNetService.ErrorCode.cancelledError) {
+    func cancel(domain d: String = DNSSDNetService.netServiceErrorDomain, error e: Any = DNSSDNetService.ErrorCode.cancelledError) {
         if let sd = sd {
             DNSServiceRefDeallocate(sd)
             self.sd = nil
-            let dict: DNSSDNetService.ErrorDictionary = [
-                DNSSDNetService.errorDomain : domain,
-                DNSSDNetService.errorCode   : error
-            ]
-            if isResolving {
-                isResolving = false
-                delegate?.netService(self, didNotResolve: dict)
-            }
-            if isPublishing {
-                isPublishing = false
-                delegate?.netService(self, didNotPublish: dict)
-            }
+            finished(domain: d, error: e)
         }
     }
 

        lastError = Int(DNSServiceProcessResult(sd))
    }

    /// Publish the net service.  This function returns immediately.
    ///
    /// - Parameter options: publishing options

            let this = Unmanaged<DNSSDNetService>.fromOpaque(context).takeRetainedValue()
            if let name = name, let n = String(validatingUTF8: name) { this._name = n }
            if let host = host, let h = String(validatingUTF8: host) { this.hostName = h }
            this.isResolving = false
            this.lastError = Int(err)
            this.finished()
        }, this))
        guard lastError == kDNSServiceErr_NoError else {
            delegate?.netService(self, didNotResolve: errorDictionary)
