]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/listener/class_BaseListener.php
Package class renamed, continued (sorry for lame description)
[hub.git] / application / hub / main / listener / class_BaseListener.php
index 31809ff5a0e80884d8426590bf8d53d58dc553f4..16d79a93a95d4944d9fc303ec6b4c97dd236a043 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Hub Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -21,7 +21,7 @@
  * 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;
 
@@ -55,6 +55,11 @@ class BaseListener extends BaseHubSystem {
         */
        private $poolInstance = null;
 
+       /**
+        * A network package handler instance
+        */
+       private $packageInstance = null;
+
        /**
         * Protected constructor
         *
@@ -111,7 +116,7 @@ class BaseListener extends BaseHubSystem {
         * @return      void
         */
        public final function setListenAddressByConfiguration ($configEntry) {
-               $this->setListenAddress($this->getConfigInstance()->readConfig($configEntry));
+               $this->setListenAddress($this->getConfigInstance()->getConfigEntry($configEntry));
        }
 
        /**
@@ -121,7 +126,7 @@ class BaseListener extends BaseHubSystem {
         * @return      void
         */
        public final function setListenPortByConfiguration ($configEntry) {
-               $this->setListenPort($this->getConfigInstance()->readConfig($configEntry));
+               $this->setListenPort($this->getConfigInstance()->getConfigEntry($configEntry));
        }
 
        /**
@@ -169,7 +174,7 @@ class BaseListener extends BaseHubSystem {
         * @return      void
         */
        protected final function setSocketResource ($socketResource) {
-               $this->socketResource = $setSocketResource;
+               $this->socketResource = $socketResource;
        }
 
        /**
@@ -177,7 +182,7 @@ class BaseListener extends BaseHubSystem {
         *
         * @return      $socketResource         The socket resource we shall set
         */
-       protected final function getSocketResource () {
+       public final function getSocketResource () {
                return $this->socketResource;
        }
 
@@ -188,7 +193,7 @@ class BaseListener extends BaseHubSystem {
         * @return      void
         */
        protected final function setPoolInstance (PoolableClient $poolInstance) {
-               $this->poolInstance = $setPoolInstance;
+               $this->poolInstance = $poolInstance;
        }
 
        /**
@@ -199,6 +204,47 @@ class BaseListener extends BaseHubSystem {
        protected final function getPoolInstance () {
                return $this->poolInstance;
        }
+
+       /**
+        * Setter for network package handler instance
+        *
+        * @param       $packageInstance        The network package handler instance we shall set
+        * @return      void
+        */
+       protected final function setPackageInstance (Networkable $packageInstance) {
+               $this->packageInstance = $packageInstance;
+       }
+
+       /**
+        * Getter for network package handler instance
+        *
+        * @return      $packageInstance        The network package handler instance we shall set
+        */
+       protected final function getPackageInstance () {
+               return $this->packageInstance;
+       }
+
+       /**
+        * Accepts the visitor to process the visit "request"
+        *
+        * @param       $visitorInstance        An instance of a Visitor class
+        * @return      void
+        */
+       public function accept (Visitor $visitorInstance) {
+               // Debug message
+               //* DEBUG: */ $this->debugOutput('LISTENER: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - START');
+
+               // Visit this listener
+               $visitorInstance->visitListener($this);
+
+               // Visit the pool if set
+               if ($this->getPoolInstance() instanceof Poolable) {
+                       $this->getPoolInstance()->accept($visitorInstance);
+               } // END - if
+
+               // Debug message
+               //* DEBUG: */ $this->debugOutput('LISTENER: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - FINISHED');
+       }
 }
 
 // [EOF]