*
* @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
*
* 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;
*/
private $poolInstance = null;
+ /**
+ * A network package handler instance
+ */
+ private $packageInstance = null;
+
/**
* Protected constructor
*
* @return void
*/
public final function setListenAddressByConfiguration ($configEntry) {
- $this->setListenAddress($this->getConfigInstance()->readConfig($configEntry));
+ $this->setListenAddress($this->getConfigInstance()->getConfigEntry($configEntry));
}
/**
* @return void
*/
public final function setListenPortByConfiguration ($configEntry) {
- $this->setListenPort($this->getConfigInstance()->readConfig($configEntry));
+ $this->setListenPort($this->getConfigInstance()->getConfigEntry($configEntry));
}
/**
* @return void
*/
protected final function setSocketResource ($socketResource) {
- $this->socketResource = $setSocketResource;
+ $this->socketResource = $socketResource;
}
/**
*
* @return $socketResource The socket resource we shall set
*/
- protected final function getSocketResource () {
+ public final function getSocketResource () {
return $this->socketResource;
}
* @return void
*/
protected final function setPoolInstance (PoolableClient $poolInstance) {
- $this->poolInstance = $setPoolInstance;
+ $this->poolInstance = $poolInstance;
}
/**
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]