     fileprivate func transportDidClose(_ error: Error?) {
         logger.log(logLevel: .info, message: "Transport closed")
 
-        let previousState = changeState(from: nil, to: State.stopped)
+        let previousState = changeState(from: nil, to: .stopped)
         logger.log(logLevel: .debug, message: "Previous state \(previousState!)")
 
-        if previousState == State.connecting {
+        if previousState == .connecting {
             logger.log(logLevel: .debug, message: "Leaving startDispatchGroup (\(#function): \(#line))")
             // unblock the dispatch group if transport closed when starting (likely due to an error)
             startDispatchGroup.leave()

    fileprivate func transportDidOpen() {
        logger.log(logLevel: .info, message: "Transport started")

        let previousState = changeState(from: State.connecting, to: State.connected)

        logger.log(logLevel: .debug, message: "Leaving startDispatchGroup (\(#function): \(#line))")
        startDispatchGroup.leave()

        self.url = url
        self.options = options
        self.logger = logger
        self.state = .initial
        self.transportDelegate = ConnectionTransportDelegate(connection: self)
    }

    public func start(transport: Transport? = nil) {
        logger.log(logLevel: .info, message: "Starting connection")

        if changeState(from: .initial, to: .connecting) == nil {
            logger.log(logLevel: .error, message: "Starting connection failed - invalid state")
            // the connection is already in use so the startDispatchGroup should not be touched to not affect it
            failOpenWithError(error: SignalRError.invalidState, changeState: false, leaveStartDispatchGroup: false)
