                         failBlock(error)
                     }
                     else{
-                       self.delegate?.websocketDidDisconnect!(error)
+                       self.delegate!.websocketDidDisconnect(error)
                     }
                     
                     writeError(errCode)

        if totalSize > 0 {
            if validateResponse(buffer, bufferLen: totalSize) {
                dispatch_async(dispatch_get_main_queue(),{
                    self.workaroundMethod()
                    if let connectBlock = self._connectedBlock{
                        connectBlock()
                    }
                    else{
                        self.delegate?.websocketDidConnect!()
                    }
                })
                totalSize += 1 //skip the last \n

            var offset = 2
            if((isMasked > 0 || (RSVMask & buffer[0]) > 0) && receivedOpcode != OpCode.Pong.rawValue) {
                let errCode = CloseCode.ProtocolError.rawValue
                let error = self.errorWithDetail("masked and rsv data is not currently supported", code: errCode)
                if let failBlock = self._failureBlock{
                    failBlock(error)
                }
                else{
                    self.delegate!.websocketDidDisconnect(error)
                }
                writeError(errCode)
                    
