         do {
             switch event {
             case .disconnected:
+                // TODO: this is wrong, we may want to reconnect. and then call connectionCompletionBlock if available.
                 self.reset()
             case .binary(let data):
                 let subscription = try self.subscriptionSerializer.serialize(data: data)

        }
    }
    
    public func connect(completion: WebSocketConnected?) {
        guard self.state != .connected else {
            completion?(.success(true))
            return
        }
        
        self.connectionCompletionBlock = completion
        self.webSocket.connect()
    }
    
    public func disconnect() {
        guard self.state != .disconnected else {
            return
        }
        
        self.queue.async {
            // TODO: Possible return something to the user if this fails?
            if let payload = try? GraphQLWSProtocol.connectionTerminate.serializedSubscriptionPayload() {
                self.write(payload)
            }
            
            self.webSocket.disconnect()
        }
    }
    
    public func subscribe<R: Request>(request: SubscriptionRequest<R>, responseHandler: SubscriptionResponseHandler) {
        self.connect { (result) in
            switch result {
            case let .success(isConnected):
                if isConnected {

                self.didReceive(subscription: subscription)
            case .connected:
                try self.connectionInitiated()
                // TOOD: what is this trying to do?
                if self.state == .connected {
                    self.subscriptions.forEach { (_, value) in
                        self.write(value)
                    }
                }
                
