- // Sanity-check on it
- if (is_null($nodeInstance)) {
- // Throws a NullPointerException here
- throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
- } // END - if
-
- // -------------------------- Hub activation --------------------------
- // Activates the hub by doing some final preparation steps and setting
- // the attribute $hubIsActive to true
- $nodeInstance->activateHub($requestInstance, $responseInstance);
-
- // ----------------------------- Main loop ----------------------------
- // This is the main loop. Queried calls should come back here very fast
- // so the whole application runs on nice speed. This while-loop goes
- // until the hub is no longer active.
- //while ($nodeInstance->isHubActive()) {
- //} // END - while
+ // Add some node-specific filters, e.g. announcement
+ $nodeInstance->addExtraNodeFilters();
+
+ /*
+ * -------------------------- Hub activation --------------------------
+ * Activates the node by doing some final preparation steps and setting
+ * the attribute $hubIsActive to true
+ */
+ $nodeInstance->activateNode($requestInstance, $responseInstance);
+
+ // Get task handler instance
+ $handlerInstance = Registry::getRegistry()->getInstance('task');
+
+ // Debug message
+ $this->debugOutput('MAIN: --- Entering main loop. ---');
+
+ /*
+ * ----------------------------- Main loop ----------------------------
+ * This is the main loop. Queried calls should come back here very fast
+ * so the whole application runs on nice speed. This while-loop goes
+ * until the hub is no longer active or all tasks are killed.
+ */
+ while (($nodeInstance->getIsActive()) && ($handlerInstance->hasTasksLeft())) {
+ // Handle all tasks here
+ $handlerInstance->handleTasks();
+ } // END - while
+
+ // Debug message
+ $this->debugOutput('MAIN: --- Leaving main loop. ---');