     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()


    public func send(data: Data, sendDidComplete: (_ error: Error?) -> Void) {
        logger.log(logLevel: .debug, message: "Sending data")
        if state != .connected {
            logger.log(logLevel: .error, message: "Sending data failed - connection not in the 'connected' state")
            sendDidComplete(SignalRError.invalidState)
            return
