application/hub/interfaces/states/client/class_ClientStateable.php -text
application/hub/interfaces/states/hub/.htaccess -text
application/hub/interfaces/states/hub/class_HubStateable.php -text
+application/hub/interfaces/visitor/.htaccess -text
+application/hub/interfaces/visitor/class_Visitable.php -text
application/hub/loader.php -text
application/hub/main/.htaccess -text
application/hub/main/class_ -text
application/hub/main/filter/node/class_NodeInitializationFilter.php -text
application/hub/main/filter/shutdown/.htaccess -text
application/hub/main/filter/shutdown/class_HubShutdown -text
+application/hub/main/filter/shutdown/class_HubShutdownDeinitQueuesFilter.php -text
application/hub/main/filter/shutdown/class_HubShutdownFlushNodeListFilter.php -text
-application/hub/main/filter/shutdown/class_HubShutdownShutdownNodeFilter.php -text
+application/hub/main/filter/shutdown/class_HubShutdownListenerPoolFilter.php -text
+application/hub/main/filter/shutdown/class_HubShutdownNodeFilter.php -text
application/hub/main/listener/.htaccess -text
application/hub/main/listener/class_ -text
application/hub/main/listener/class_BaseListener.php -text
// -------------------------- Shutdown phase --------------------------
// Shutting down the hub by saying "good bye" to all connected clients
// and other hubs, flushing all queues and caches.
+ $this->debugOutput('MAIN: Shutdown in progress, main loop exited.');
$this->getControllerInstance()->executeShutdownFilters($requestInstance, $responseInstance);
+ $this->debugOutput('MAIN: Shutdown completed. (This is the last line.)');
}
/**
// CFG: HUB-SHUTDOWN-FLUSH-NODE-LIST-FILTER
$cfg->setConfigEntry('hub_shutdown_flush_node_list_filter', 'HubShutdownFlushNodeListFilter');
-// CFG: HUB-SHUTDOWN-SHUTDOWN-NODE-FILTER
-$cfg->setConfigEntry('hub_shutdown_shutdown_node_filter', 'HubShutdownShutdownNodeFilter');
+// CFG: HUB-SHUTDOWN-DEINIT-QUEUES-FILTER
+$cfg->setConfigEntry('hub_shutdown_deinit_queues_filter', 'HubShutdownDeinitQueuesFilter');
+
+// CFG: HUB-SHUTDOWN-LISTENER-POOL-FILTER
+$cfg->setConfigEntry('hub_shutdown_listener_pool_filter', 'HubShutdownListenerPoolFilter');
+
+// CFG: HUB-SHUTDOWN-NODE-FILTER
+$cfg->setConfigEntry('hub_shutdown_node_filter', 'HubShutdownNodeFilter');
// CFG: NEWS-READER-CLASS
$cfg->setConfigEntry('news_reader_class', 'ConsoleNewsReader');
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-interface Listenable extends FrameworkInterface {
+interface Listenable {
/**
* Initializes the listener by setting up the required socket server
*
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for the visitor pattern
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface Visitable extends FrameworkInterface {
+}
+
+//
+?>
// Add shutdown filters
$controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('hub_shutdown_flush_node_list_filter'));
- $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('hub_shutdown_shutdown_node_filter'));
+ $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('hub_shutdown_deinit_queues_filter'));
+ $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('hub_shutdown_listener_pool_filter'));
+
+ // This is the last filter
+ $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('hub_shutdown_node_filter'));
}
}
// [EOF]
?>
-<?php
-/**
- * A ??? filter for shutting down the node.
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class HubShutdown???Filter extends BaseFilter implements Filterable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this filter class
- *
- * @return $filterInstance An instance of this filter class
- */
- public final static function createHubShutdown???Filter () {
- // Get a new instance
- $filterInstance = new HubShutdown???Filter();
-
- // Return the instance
- return $filterInstance;
- }
-
- /**
- * Executes the filter with given request and response objects
- *
- * @param $requestInstance An instance of a class with an Requestable interface
- * @param $responseInstance An instance of a class with an Responseable interface
- * @return void
- * @throws FilterChainException If $nodeInstance is null (no NullPointerException here)
- * @todo 0% done
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get node instance
- $nodeInstance = Registry::getRegistry()->getInstance('node');
-
- // Sanity-check on it
- if (is_null($nodeInstance)) {
- // Throws a FilterChainException to stop further processing
- throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
- } // END - if
-
- // Now do something
- $this->partialStub('Please implement this step.');
- }
-}
-
-// [EOF]
-?>
--- /dev/null
+<?php
+/**
+ * A DeinitQueues filter for shutting down the node.
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class HubShutdownDeinitQueuesFilter extends BaseFilter implements Filterable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public final static function createHubShutdownDeinitQueuesFilter () {
+ // Get a new instance
+ $filterInstance = new HubShutdownDeinitQueuesFilter();
+
+ // Return the instance
+ return $filterInstance;
+ }
+
+ /**
+ * Executes the filter with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ * @throws FilterChainException If $nodeInstance is null (no NullPointerException here)
+ * @todo 0% done
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get node instance
+ $nodeInstance = Registry::getRegistry()->getInstance('node');
+
+ // Sanity-check on it
+ if (is_null($nodeInstance)) {
+ // Throws a FilterChainException to stop further processing
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
+ } // END - if
+
+ // Get query instance
+ $queryInstance = $nodeInstance->getQueryInstance();
+
+ // Sanity-check on it
+ if (is_null($queryInstance)) {
+ // Throws a FilterChainException to stop further processing
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
+ } // END - if
+
+ // Now shutdown this one done
+ $queryInstance->doShutdown();
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A ListenerPool filter for shutting down the node.
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class HubShutdownListenerPoolFilter extends BaseFilter implements Filterable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public final static function createHubShutdownListenerPoolFilter () {
+ // Get a new instance
+ $filterInstance = new HubShutdownListenerPoolFilter();
+
+ // Return the instance
+ return $filterInstance;
+ }
+
+ /**
+ * Executes the filter with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ * @throws FilterChainException If $nodeInstance is null (no NullPointerException here)
+ * @todo 0% done
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get node instance
+ $nodeInstance = Registry::getRegistry()->getInstance('node');
+
+ // Sanity-check on it
+ if (is_null($nodeInstance)) {
+ // Throws a FilterChainException to stop further processing
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
+ } // END - if
+
+ // Get listener pool instance
+ $listenerPoolInstance = $nodeInstance->getListenerPoolInstance();
+
+ // Sanity-check on it
+ if (is_null($listenerPoolInstance)) {
+ // Throws a FilterChainException to stop further processing
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
+ } // END - if
+
+ // Now shutdown this one done
+ $listenerPoolInstance->doShutdown();
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A ShutdownNode filter for shutting down the node. This filter should be the
+ * last one in 'shutdown' chain so the hub is shutted down at the very end of
+ * its life... R.I.P. little hub...
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class HubShutdownNodeFilter extends BaseFilter implements Filterable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public final static function createHubShutdownNodeFilter () {
+ // Get a new instance
+ $filterInstance = new HubShutdownNodeFilter();
+
+ // Return the instance
+ return $filterInstance;
+ }
+
+ /**
+ * Executes the filter with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ * @throws FilterChainException If $nodeInstance is null (no NullPointerException please)
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get node instance
+ $nodeInstance = Registry::getRegistry()->getInstance('node');
+
+ // Sanity-check on it
+ if (is_null($nodeInstance)) {
+ // Throws a FilterChainException to stop further processing
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
+ } // END - if
+
+ // Shutdown the node. This should be the last line
+ $nodeInstance->doShutdown();
+ }
+}
+
+// [EOF]
+?>
+++ /dev/null
-<?php
-/**
- * A ShutdownNode filter for shutting down the node. This filter should be the
- * last one in 'shutdown' chain so the hub is shutted down at the very end of
- * its life... R.I.P. little hub...
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class HubShutdownShutdownNodeFilter extends BaseFilter implements Filterable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this filter class
- *
- * @return $filterInstance An instance of this filter class
- */
- public final static function createHubShutdownShutdownNodeFilter () {
- // Get a new instance
- $filterInstance = new HubShutdownShutdownNodeFilter();
-
- // Return the instance
- return $filterInstance;
- }
-
- /**
- * Executes the filter with given request and response objects
- *
- * @param $requestInstance An instance of a class with an Requestable interface
- * @param $responseInstance An instance of a class with an Responseable interface
- * @return void
- * @throws FilterChainException If $nodeInstance is null (no NullPointerException please)
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get node instance
- $nodeInstance = Registry::getRegistry()->getInstance('node');
-
- // Sanity-check on it
- if (is_null($nodeInstance)) {
- // Throws a FilterChainException to stop further processing
- throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
- } // END - if
-
- // Shutdown the node. This should be the last line
- $nodeInstance->doShutdown();
- }
-}
-
-// [EOF]
-?>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class ???Listener extends BaseListener implements Listenable {
+class ???Listener extends BaseListener implements Listenable, Visitable {
/**
* Protected constructor
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class BaseListener extends BaseHubSystem {
+class BaseListener extends BaseHubSystem implements Visitable {
// Exception code constants
const EXCEPTION_INVALID_SOCKET = 0xa00;
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class BaseListenerDecorator extends BaseHubSystem {
+class BaseListenerDecorator extends BaseHubSystem implements Visitable {
/**
* Protected constructor
*
return $this->nodeId;
}
+ /**
+ * Setter for listener pool instance
+ *
+ * @param $listenerPoolInstance Our new listener pool instance
+ * @return void
+ */
+ private final function setListenerPoolInstance (PoolableListener $listenerPoolInstance) {
+ $this->listenerPoolInstance = $listenerPoolInstance;
+ }
+
+ /**
+ * Getter for listener pool instance
+ *
+ * @return $listenerPoolInstance Our current listener pool instance
+ */
+ public final function getListenerPoolInstance () {
+ return $this->listenerPoolInstance;
+ }
+
/**
* Setter for session id
*
*
* @return $sessionId Our new session id
*/
- private final function getSessionId () {
+ public final function getSessionId () {
return $this->sessionId;
}
*
* @return $queryInstance Our new query instance
*/
- protected final function getQueryInstance () {
+ public final function getQueryInstance () {
return $this->queryInstance;
}
+ /**
+ * Getter for boot IP/port combination
+ *
+ * @return $bootIpPort The IP/port combination of the boot node
+ */
+ protected final function getBootIpPort () {
+ return $this->bootIpPort;
+ }
+
/**
* Checks wether the given IP address matches one of the bootstrapping nodes
*
$this->debugOutput('BOOTSTRAP: Created new session-id: ' . $this->getSessionId() . '');
}
- /**
- * Getter for boot IP/port combination
- *
- * @return $bootIpPort The IP/port combination of the boot node
- */
- protected final function getBootIpPort () {
- return $this->bootIpPort;
- }
-
/**
* Initializes queues which every node needs
*
$this->debugOutput('HUB: Initialize listener: START');
// Get a new pool instance
- $this->listenerPoolInstance = ObjectFactory::createObjectByConfiguredName('listener_pool_class', array($this));
+ $this->setListenerPoolInstance(ObjectFactory::createObjectByConfiguredName('listener_pool_class', array($this)));
// Get an instance of the low-level listener
$listenerInstance = ObjectFactory::createObjectByConfiguredName('tcp_listener_class', array($this));
$decoratorInstance = ObjectFactory::createObjectByConfiguredName('hub_tcp_listener_class', array($listenerInstance));
// Add this listener to the pool
- $this->listenerPoolInstance->addListener($decoratorInstance);
+ $this->getListenerPoolInstance()->addListener($decoratorInstance);
// Get a decorator class
$decoratorInstance = ObjectFactory::createObjectByConfiguredName('client_tcp_listener_class', array($listenerInstance));
// Add this listener to the pool
- $this->listenerPoolInstance->addListener($decoratorInstance);
+ $this->getListenerPoolInstance()->addListener($decoratorInstance);
// Get an instance of the low-level listener
$listenerInstance = ObjectFactory::createObjectByConfiguredName('udp_listener_class', array($this));
$decoratorInstance = ObjectFactory::createObjectByConfiguredName('hub_udp_listener_class', array($listenerInstance));
// Add this listener to the pool
- $this->listenerPoolInstance->addListener($decoratorInstance);
+ $this->getListenerPoolInstance()->addListener($decoratorInstance);
// Get a decorator class
$decoratorInstance = ObjectFactory::createObjectByConfiguredName('client_udp_listener_class', array($listenerInstance));
// Add this listener to the pool
- $this->listenerPoolInstance->addListener($decoratorInstance);
+ $this->getListenerPoolInstance()->addListener($decoratorInstance);
// Debug output
$this->debugOutput('HUB: Initialize listener: FINISHED.');
* @param $poolSegment Name of the pool segment
* @param $instance An instance of a class we should add to the pool
* @return void
- * @todo Can we use Listenable instead of FrameworkInterface ?
*/
- protected final function addInstance($group, $poolName, FrameworkInterface $instance) {
+ protected final function addInstance ($group, $poolName, Visitable $instance) {
$this->poolEntries[$group][$poolName][] = $instance;
}