Kaa:onStarted() 是什么时候在 main 中被调用的?

Kaa: When onStarted() was called in main?

想了解 onStarted() 是如何被调用的。 kaaClient.start() 是否执行了 onStarted()?我尝试使用 ecplise 进行调试,发现它总是在执行 "sleepForSeconds(MAX_SECONDS_TO_INIT_KAA);" 之前执行 "LOG.info("--= Kaa 客户端已启动 =--")" 但我不知道 onStarted() 何时执行。

   public static void main(String[] args) {
        LOG.info("--= Data collection demo started =--");

        /*
         * Create a Kaa client with the Kaa desktop context.
         */
        KaaClient kaaClient = Kaa.newClient(new DesktopKaaPlatformContext(), new SimpleKaaClientStateListener() {
            @Override
            public void onStarted() {
                LOG.info("--= Kaa client started =--");
            }

            @Override
            public void onStopped() {
                LOG.info("--= Kaa client stopped =--");
            }
        }, true);

        /*
         * Set record count strategy for uploading every log record as soon as it is created.
         */
        kaaClient.setLogUploadStrategy(new RecordCountLogUploadStrategy(LOGS_DEFAULT_THRESHOLD));

        /*
         * Displays endpoint's configuration and change sampling period each time configuration will be updated.
         */
        kaaClient.addConfigurationListener(new ConfigurationListener() {
            @Override
            public void onConfigurationUpdate(Configuration configuration) {
                LOG.info("--= Endpoint configuration was updated =--");
                displayConfiguration(configuration);

                Integer newSamplePeriod = configuration.getSamplePeriod();
                if ((newSamplePeriod != null) && (newSamplePeriod > 0)) {
                    changeMeasurementPeriod(kaaClient, newSamplePeriod);
                } else {
                    LOG.warn("Sample period value (= {}) in updated configuration is wrong, so ignore it.", newSamplePeriod);
                }
            }
        });

        /*
         * Start the Kaa client and connect it to the Kaa server.
         */
        kaaClient.start();
        sleepForSeconds(MAX_SECONDS_TO_INIT_KAA);

        /*
         * Start periodical temperature value generating and sending results to Kaa node
         */
        startMeasurement(kaaClient);

        LOG.info("*** Press Enter to stop sending log records ***");
        waitForAnyInput();

        /*
         * Stop generating and sending data to Kaa node
         */
        stopMeasurement();

        /*
         * Stop the Kaa client and release all the resources which were in use.
         */
        kaaClient.stop();
        displayResults();
        LOG.info("--= Data collection demo stopped =--");
    }

方法 onStarted()start() 方法中调用。有关详细信息,请参阅 AbstaractKaaClient