 
     func mqttDidReceivePong(_ mqtt: CocoaMQTT)
 
-    func mqttDidDisconnect(_ mqtt: CocoaMQTT, withError err: NSError?)
+    func mqttDidDisconnect(_ mqtt: CocoaMQTT, withError err: Error?)
 
 }
 

            reader!.payloadReady(data)
        }
    }

    @nonobjc open func socketDidDisconnect(_ sock: GCDAsyncSocket, withError err: NSError?) {
        connState = CocoaMQTTConnState.disconnected
        delegate?.mqttDidDisconnect(self, withError: err)
    }

        }
    }
    
    public func socket(_ sock: GCDAsyncSocket, didReceive trust: SecTrust, completionHandler: @escaping (Bool) -> Swift.Void) {
        #if DEBUG
            NSLog("CocoaMQTT: didReceiveTrust")
        #endif
        completionHandler(true)
    }
    
    public func socketDidSecure(_ sock: GCDAsyncSocket) {
        #if DEBUG
            NSLog("CocoaMQTT: socketDidSecure")
        #endif
        sendConnectFrame()
    }

    public func socket(_ sock: GCDAsyncSocket, didWriteDataWithTag tag: Int) {
        #if DEBUG
        NSLog("CocoaMQTT: Socket write message with tag: \(tag)")
        #endif
    }
    
    public func socket(_ sock: GCDAsyncSocket, didRead data: Data, withTag tag: Int) {
        let etag: CocoaMQTTReadTag = CocoaMQTTReadTag(rawValue: tag)!
        var bytes = [UInt8]([0])
        switch etag {
