]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/listener/class_BaseListener.php
Listener classes added, setter/getter added
[hub.git] / application / hub / main / listener / class_BaseListener.php
index ababd57ed1e9880bc67f94451729e905cdf78c66..f86ff5100af73dce28d42750d3b9dd1ef8f62dd6 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 class BaseListener extends BaseHubSystem {
+       /**
+        * Address (IP mostly) we shall listen on
+        */
+       private $listenAddress = '0.0.0.0'; // This is the default and listens on all interfaces
+
+       /**
+        * Port we shall listen on (or wait for incoming data)
+        */
+       private $listenPort = 0; // This port MUST be changed by your application
+
+       /**
+        * Wether we are in blocking or non-blocking mode (default: non-blocking
+        */
+       private $blockingMode = false;
+
        /**
         * Protected constructor
         *
@@ -32,6 +47,64 @@ class BaseListener extends BaseHubSystem {
                // Call parent constructor
                parent::__construct($className);
        }
+
+       /**
+        * Setter for listen address
+        *
+        * @param       $listenAddress  The address this listener should listen on
+        * @return      void
+        */
+       protected final function setListenAddress ($listenAddress) {
+               $this->listenAddress = (string) $listenAddress;
+       }
+
+       /**
+        * Getter for listen address
+        *
+        * @return      $listenAddress  The address this listener should listen on
+        */
+       public final function getListenAddress () {
+               return $this->listenAddress;
+       }
+
+       /**
+        * Setter for listen port
+        *
+        * @param       $listenPort             The port this listener should listen on
+        * @return      void
+        */
+       protected final function setListenPort ($listenPort) {
+               $this->listenPort = (int) $listenPort;
+       }
+
+       /**
+        * Getter for listen port
+        *
+        * @return      $listenPort             The port this listener should listen on
+        */
+       public final function getListenPort () {
+               return $this->listenPort;
+       }
+
+       /**
+        * "Setter" to set listen address from configuration entry
+        *
+        * @param       $configEntry    The configuration entry holding our listen address
+        * @return      void
+        */
+       public final function setListenAddressByConfiguration ($configEntry) {
+               $this->setListenAddress($this->getConfigInstance()->readConfig($configEntry));
+       }
+
+       /**
+        * "Setter" to set listen port from configuration entry
+        *
+        * @param       $configEntry    The configuration entry holding our listen port
+        * @return      void
+        */
+       public final function setListenPortByConfiguration ($configEntry) {
+               $this->setListenPort($this->getConfigInstance()->readConfig($configEntry));
+       }
 }
 
 // [EOF]