]> git.mxchange.org Git - hub.git/blob - application/hub/main/listener/class_BaseListener.php
Grouping by protocol of listeners in pool 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 Hub 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          * Used protocol (Default: invalid, which is invalid...)
27          */
28         private $protcol = 'invalid';
29
30         /**
31          * Address (IP mostly) we shall listen on
32          */
33         private $listenAddress = '0.0.0.0'; // This is the default and listens on all interfaces
34
35         /**
36          * Port we shall listen on (or wait for incoming data)
37          */
38         private $listenPort = 0; // This port MUST be changed by your application
39
40         /**
41          * Wether we are in blocking or non-blocking mode (default: non-blocking
42          */
43         private $blockingMode = false;
44
45         /**
46          * Protected constructor
47          *
48          * @param       $className      Name of the class
49          * @return      void
50          */
51         protected function __construct ($className) {
52                 // Call parent constructor
53                 parent::__construct($className);
54         }
55
56         /**
57          * Setter for listen address
58          *
59          * @param       $listenAddress  The address this listener should listen on
60          * @return      void
61          */
62         protected final function setListenAddress ($listenAddress) {
63                 $this->listenAddress = (string) $listenAddress;
64         }
65
66         /**
67          * Getter for listen address
68          *
69          * @return      $listenAddress  The address this listener should listen on
70          */
71         public final function getListenAddress () {
72                 return $this->listenAddress;
73         }
74
75         /**
76          * Setter for listen port
77          *
78          * @param       $listenPort             The port this listener should listen on
79          * @return      void
80          */
81         protected final function setListenPort ($listenPort) {
82                 $this->listenPort = (int) $listenPort;
83         }
84
85         /**
86          * Getter for listen port
87          *
88          * @return      $listenPort             The port this listener should listen on
89          */
90         public final function getListenPort () {
91                 return $this->listenPort;
92         }
93
94         /**
95          * "Setter" to set listen address from configuration entry
96          *
97          * @param       $configEntry    The configuration entry holding our listen address
98          * @return      void
99          */
100         public final function setListenAddressByConfiguration ($configEntry) {
101                 $this->setListenAddress($this->getConfigInstance()->readConfig($configEntry));
102         }
103
104         /**
105          * "Setter" to set listen port from configuration entry
106          *
107          * @param       $configEntry    The configuration entry holding our listen port
108          * @return      void
109          */
110         public final function setListenPortByConfiguration ($configEntry) {
111                 $this->setListenPort($this->getConfigInstance()->readConfig($configEntry));
112         }
113
114         /**
115          * Setter for protocol
116          *
117          * @param       $protocol       Used protocol
118          * @return      void
119          */
120         protected final function setProtocol ($protocol) {
121                 $this->protocol = (string) $protocol;
122         }
123
124         /**
125          * Getter for protocol
126          *
127          * @return      $protocol       Used protocol
128          */
129         public final function getProtocol () {
130                 return $this->protocol;
131         }
132 }
133
134 // [EOF]
135 ?>