]> git.mxchange.org Git - hub.git/blob - application/hub/main/listener/class_BaseListener.php
Listener classes added, setter/getter added
[hub.git] / application / hub / main / listener / class_BaseListener.php
1 <?php
2 /**
3  * A general listener class
4  *
5  * @author              Roland Haeder <webmaster@ship-simu.org>
6  * @version             0.0.0
7  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
8  * @license             GNU GPL 3.0 or any newer version
9  * @link                http://www.ship-simu.org
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23  */
24 class BaseListener extends BaseHubSystem {
25         /**
26          * Address (IP mostly) we shall listen on
27          */
28         private $listenAddress = '0.0.0.0'; // This is the default and listens on all interfaces
29
30         /**
31          * Port we shall listen on (or wait for incoming data)
32          */
33         private $listenPort = 0; // This port MUST be changed by your application
34
35         /**
36          * Wether we are in blocking or non-blocking mode (default: non-blocking
37          */
38         private $blockingMode = false;
39
40         /**
41          * Protected constructor
42          *
43          * @param       $className      Name of the class
44          * @return      void
45          */
46         protected function __construct ($className) {
47                 // Call parent constructor
48                 parent::__construct($className);
49         }
50
51         /**
52          * Setter for listen address
53          *
54          * @param       $listenAddress  The address this listener should listen on
55          * @return      void
56          */
57         protected final function setListenAddress ($listenAddress) {
58                 $this->listenAddress = (string) $listenAddress;
59         }
60
61         /**
62          * Getter for listen address
63          *
64          * @return      $listenAddress  The address this listener should listen on
65          */
66         public final function getListenAddress () {
67                 return $this->listenAddress;
68         }
69
70         /**
71          * Setter for listen port
72          *
73          * @param       $listenPort             The port this listener should listen on
74          * @return      void
75          */
76         protected final function setListenPort ($listenPort) {
77                 $this->listenPort = (int) $listenPort;
78         }
79
80         /**
81          * Getter for listen port
82          *
83          * @return      $listenPort             The port this listener should listen on
84          */
85         public final function getListenPort () {
86                 return $this->listenPort;
87         }
88
89         /**
90          * "Setter" to set listen address from configuration entry
91          *
92          * @param       $configEntry    The configuration entry holding our listen address
93          * @return      void
94          */
95         public final function setListenAddressByConfiguration ($configEntry) {
96                 $this->setListenAddress($this->getConfigInstance()->readConfig($configEntry));
97         }
98
99         /**
100          * "Setter" to set listen port from configuration entry
101          *
102          * @param       $configEntry    The configuration entry holding our listen port
103          * @return      void
104          */
105         public final function setListenPortByConfiguration ($configEntry) {
106                 $this->setListenPort($this->getConfigInstance()->readConfig($configEntry));
107         }
108 }
109
110 // [EOF]
111 ?>