// 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->determineIfHubIsActive()) && ($handlerInstance->hasTasksLeft())) {
+ while (($nodeInstance->getIsActive()) && ($handlerInstance->hasTasksLeft())) {
// Handle all tasks here
$handlerInstance->handleTasks();
} // END - while
*/
private $stateInstance = null;
+ /**
+ * Wether this hub is active
+ */
+ private $isActive = false;
+
/**
* Protected constructor
*
public function activateHub (Requestable $requestInstance, Responseable $responseInstance) {
// Checks wether a listener is still active and shuts it down if one
// is still listening.
- if (($this->determineIfListenerIsActive()) && ($this->determineIfHubIsActive())) {
+ if (($this->determineIfListenerIsActive()) && ($this->getIsActive())) {
// Shutdown them down before they can hurt anything
$this->shutdownListenerPool();
} // END - if
}
/**
- * Determines wether the hub is active by checking its current state
+ * Getter for isActive attribute
*
* @return $isActive Wether the hub is active
*/
- public function determineIfHubIsActive () {
- // Check the state
- // @TODO Add more states e.g. 'firewalled', 'senior'
- $isActive = ($this->getStateInstance() instanceof NodeActiveState);
+ public final function getIsActive () {
+ return $this->isActive;
+ }
- // Return value
- return $isActive;
+ /**
+ * Enables (default) or disables isActive flag
+ *
+ * @param $isActive Wether the hub is active
+ * @return void
+ */
+ public final function enableIsActive ($isActive = true) {
+ $this->isActive = (bool) $isActive;
}
}
// Debug message
$stateInstance->debugOutput('NODE-STATE: Has changed from ' . $nodeInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
+ // Enable isActive flag in node instance
+ $nodeInstance->enableIsActive();
+
// Set the node instance
$stateInstance->setNodeInstance($nodeInstance);