def change_to_connected_state
      return unless @http

      @max_stream_count = @http.remote_settings[:settings_max_concurrent_streams]
      @connected = true

      info "Connection established."
      debug "Maximum number of streams: #{@max_stream_count}. Flushing #{@request_queue.size} enqueued requests."

      @request_queue.size.times do
        async.try_to_perform_request!
      end

      @heartbeat = every(HEARTBEAT_INTERVAL) do
        debug "Sending heartbeat ping..."
        begin
          future.ping.call(HEARTBEAT_TIMEOUT)
          debug "Got heartbeat reply."
        rescue Celluloid::TimedOut
          raise TimedOut, "Heartbeat ping timed-out."
        end
      end
    end
def change_to_connected_state
      return unless @http

      @max_stream_count = @http.remote_settings[:settings_max_concurrent_streams]
      @connected = true

      info "Connection established."
      debug "Maximum number of streams: #{@max_stream_count}. Flushing #{@request_queue.size} enqueued requests."

      @request_queue.size.times do
        async.try_to_perform_request!
      end

      @heartbeat = every(HEARTBEAT_INTERVAL) do
        debug "Sending heartbeat ping..."
        begin
          future.ping.call(HEARTBEAT_TIMEOUT)
          debug "Got heartbeat reply."
        rescue Celluloid::TimedOut
          raise TimedOut, "Heartbeat ping timed-out."
        end
      end
    end
Called when the HTTP client changes its state to `:connected`.

 @return [void]