             }
         }
     }
-
+    
     /// Close the tunnel immediately.
     ///
     /// - note: This method is thread-safe.
     func forceClose() {
         observer?.signal(.forceCloseCalled(self))
-
+        
         guard !self.isCancelled else {
             return
         }
-
+        
         self._cancelled = true
         self._status = .closing
         self._stopForwarding = true
-
+        
         if !self.proxySocket.isDisconnected {
             self.proxySocket.forceDisconnect()
         }

            openAdapter(for: request)
        }
    }

    fileprivate func openAdapter(for request: ConnectRequest) {
        guard !isCancelled else {
            return
        }

        let manager = RuleManager.currentManager
        let factory = manager.match(request)!
        adapterSocket = factory.getAdapterFor(request: request)
        adapterSocket!.delegate = self
        adapterSocket!.openSocketWith(request: request)
    }

    public func didBecomeReadyToForwardWith(socket: SocketProtocol) {
        guard !isCancelled else {
            return
        }

        readySignal += 1
        observer?.signal(.receivedReadySignal(socket, currentReady: readySignal, on: self))

        defer {
            if let socket = socket as? AdapterSocket {
                proxySocket.respondTo(adapter: socket)

            }
        } else if let socket = socket as? AdapterSocket {
            observer?.signal(.adapterSocketWroteData(data, by: socket, on: self))
            
            guard !isCancelled else {
                return
            }
            
            proxySocket.readData()
        }
    }
    
    public func didConnectWith(adapterSocket: AdapterSocket) {
        guard !isCancelled else {
            return
        }
        
        observer?.signal(.connectedToRemote(adapterSocket, on: self))
    }
    
    public func updateAdapterWith(newAdapter: AdapterSocket) {
        guard !isCancelled else {
            return
        }
        
        observer?.signal(.updatingAdapterSocket(from: adapterSocket!, to: newAdapter, on: self))
        
        adapterSocket = newAdapter
        adapterSocket?.delegate = self
    }
    
    fileprivate func checkStatus() {
        if isClosed {
            _status = .closed
