Moved files + added interface + generic socket file listener
authorRoland Haeder <roland@mxchange.org>
Sat, 12 Sep 2015 05:54:16 +0000 (07:54 +0200)
committerRoland Haeder <roland@mxchange.org>
Sat, 12 Sep 2015 05:54:16 +0000 (07:54 +0200)
Signed-off-by: Roland Häder <roland@mxchange.org>
12 files changed:
.gitattributes [deleted file]
contrib/find-bad-php.sh [new file with mode: 0755]
contrib/todo-builder.sh [new file with mode: 0755]
contrib/update_year.sh [new file with mode: 0755]
find-bad-php.sh [deleted file]
inc/main/classes/listener/class_
inc/main/classes/listener/socket/.htaccess [new file with mode: 0644]
inc/main/classes/listener/socket/class_SocketFileListener.php [new file with mode: 0644]
inc/main/interfaces/listener/.htaccess [new file with mode: 0644]
inc/main/interfaces/listener/class_Listenable.php [new file with mode: 0644]
todo-builder.sh [deleted file]
update_year.sh [deleted file]

diff --git a/.gitattributes b/.gitattributes
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/contrib/find-bad-php.sh b/contrib/find-bad-php.sh
new file mode 100755 (executable)
index 0000000..2fdfecf
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+echo "$0: Searching for PHP scripts (except 3rd party) ..."
+PHP=`find -type f -name "*.php" | grep -v "third_party"`
+
+for SCRIPT in ${PHP};
+do
+       HEADER=`cat ${SCRIPT} | head -n 1 | grep -v "<?"`
+
+       FOOTER=`cat ${SCRIPT} | tail -n 1 | grep -v "?>"`
+
+       if [ -n "${HEADER}" ];
+       then
+               echo "$0: Script '${SCRIPT}' has non-typical header."
+       fi
+
+       if [ -n "${FOOTER}" ];
+       then
+               echo "$0: Script '${SCRIPT}' has non-typical footer."
+       fi
+
+       LINT=`php -l "${SCRIPT}" 2>&1 | grep -v "No syntax errors detected in"`
+
+       if [ -n "${LINT}" ]
+       then
+               echo "$0: ${LINT}"
+       fi
+done
+
+echo "$0: All done."
+exit 0
diff --git a/contrib/todo-builder.sh b/contrib/todo-builder.sh
new file mode 100755 (executable)
index 0000000..295b6ba
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# This script helps building the file docs/TODOs.txt and should be executed by
+# developers with SVN write-access
+
+if ! test -e "docs"; then
+  echo "$0: Please execute this script from root directory."
+  exit 1
+fi
+
+echo "$0: Generating TODOs.txt..."
+echo "### WARNING: THIS FILE IS AUTO-GENERATED BY $0 ###" > docs/TODOs.txt
+echo "### DO NOT EDIT THIS FILE. ###" >> docs/TODOs.txt
+find -type f -name "*.php" -exec grep -Hin "@TODO" {} \; | sort >> docs/TODOs.txt
+echo "### ### DEPRECATION FOLLOWS: ### ###" >> docs/TODOs.txt
+find -type f -name "*.php" -exec grep -Hin "@DEPRECATED" {} \; | sort >> docs/TODOs.txt
+echo "$0: Done."
+exit 0
diff --git a/contrib/update_year.sh b/contrib/update_year.sh
new file mode 100755 (executable)
index 0000000..062ef54
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Really lame ...
+find */ -type f -print0 | xargs -0 sed -i 's/2014 Core/2015 Core/g'
diff --git a/find-bad-php.sh b/find-bad-php.sh
deleted file mode 100755 (executable)
index 2fdfecf..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/sh
-
-echo "$0: Searching for PHP scripts (except 3rd party) ..."
-PHP=`find -type f -name "*.php" | grep -v "third_party"`
-
-for SCRIPT in ${PHP};
-do
-       HEADER=`cat ${SCRIPT} | head -n 1 | grep -v "<?"`
-
-       FOOTER=`cat ${SCRIPT} | tail -n 1 | grep -v "?>"`
-
-       if [ -n "${HEADER}" ];
-       then
-               echo "$0: Script '${SCRIPT}' has non-typical header."
-       fi
-
-       if [ -n "${FOOTER}" ];
-       then
-               echo "$0: Script '${SCRIPT}' has non-typical footer."
-       fi
-
-       LINT=`php -l "${SCRIPT}" 2>&1 | grep -v "No syntax errors detected in"`
-
-       if [ -n "${LINT}" ]
-       then
-               echo "$0: ${LINT}"
-       fi
-done
-
-echo "$0: All done."
-exit 0
index 5d3309f57c42e502a94c4345e577a1b98412dbfa..d09db71d6875060a0304a470513ded8806f11496 100644 (file)
@@ -35,16 +35,12 @@ class ???Listener extends BaseListener implements Listenable {
        /**
         * Creates an instance of this class
         *
-        * @param       $nodeInstance           A NodeHelper instance
         * @return      $listenerInstance       An instance a prepared listener class
         */
-       public final static function create???Listener (NodeHelper $nodeInstance) {
+       public final static function create???Listener () {
                // Get new instance
                $listenerInstance = new ???Listener();
 
-               // Set the application instance
-               $listenerInstance->setNodeInstance($nodeInstance);
-
                // Return the prepared instance
                return $listenerInstance;
        }
@@ -68,6 +64,62 @@ class ???Listener extends BaseListener implements Listenable {
        public function doListen() {
                $this->partialStub('Need to implement this method.');
        }
+
+       /**
+        * Checks whether the listener would accept the given package data array
+        *
+        * @param       $packageData    Raw package data
+        * @return      $accepts                Whether this listener does accept
+        */
+       public function ifListenerAcceptsPackageData (array $packageData) {
+               $this->partialStub('Need to implement this method.') {
+       }
+
+       /**
+        * Monitors incoming raw data from the handler and transfers it to the
+        * given receiver instance.
+        *
+        * @return      void
+        */
+       public function monitorIncomingRawData () {
+               $this->partialStub('Need to implement this method.') {
+       }
+
+       /**
+        * Getter for listen address
+        *
+        * @return      $listenAddress  The address this listener should listen on
+        */
+       public function getListenAddress () {
+               $this->partialStub('Need to implement this method.') {
+       }
+
+       /**
+        * Getter for listen port
+        *
+        * @return      $listenPort             The port this listener should listen on
+        */
+       public function getListenPort () {
+               $this->partialStub('Need to implement this method.') {
+       }
+
+       /**
+        * Getter for connection type
+        *
+        * @return      $connectionType         Connection type for this listener
+        */
+       public function getConnectionType () {
+               $this->partialStub('Need to implement this method.') {
+       }
+
+       /**
+        * Getter for peer pool instance
+        *
+        * @return      $poolInstance   The peer pool instance we shall set
+        */
+       public function getPoolInstance () {
+               $this->partialStub('Need to implement this method.') {
+       }
 }
 
 // [EOF]
diff --git a/inc/main/classes/listener/socket/.htaccess b/inc/main/classes/listener/socket/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/main/classes/listener/socket/class_SocketFileListener.php b/inc/main/classes/listener/socket/class_SocketFileListener.php
new file mode 100644 (file)
index 0000000..2be9dff
--- /dev/null
@@ -0,0 +1,126 @@
+<?php
+/**
+ * A file-based socket listener
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * 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 SocketFileListener extends BaseListener implements Listenable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $listenerInstance       An instance a prepared listener class
+        */
+       public final static function createSocketFileListener () {
+               // Get new instance
+               $listenerInstance = new SocketFileListener();
+
+               // Return the prepared instance
+               return $listenerInstance;
+       }
+
+       /**
+        * Initializes the listener by setting up the required socket server
+        *
+        * @return      void
+        * @todo        0% done
+        */
+       public function initListener() {
+               $this->partialStub('Need to implement this method.');
+       }
+
+       /**
+        * "Listens" for incoming network packages
+        *
+        * @return      void
+        * @todo        0% done
+        */
+       public function doListen() {
+               $this->partialStub('Need to implement this method.');
+       }
+
+       /**
+        * Checks whether the listener would accept the given package data array
+        *
+        * @param       $packageData    Raw package data
+        * @return      $accepts                Whether this listener does accept
+        */
+       public function ifListenerAcceptsPackageData (array $packageData) {
+               $this->partialStub('Need to implement this method.') {
+       }
+
+       /**
+        * Monitors incoming raw data from the handler and transfers it to the
+        * given receiver instance.
+        *
+        * @return      void
+        */
+       public function monitorIncomingRawData () {
+               $this->partialStub('Need to implement this method.') {
+       }
+
+       /**
+        * Getter for listen address
+        *
+        * @return      $listenAddress  The address this listener should listen on
+        */
+       public function getListenAddress () {
+               $this->partialStub('Need to implement this method.') {
+       }
+
+       /**
+        * Getter for listen port
+        *
+        * @return      $listenPort             The port this listener should listen on
+        */
+       public function getListenPort () {
+               $this->partialStub('Need to implement this method.') {
+       }
+
+       /**
+        * Getter for connection type
+        *
+        * @return      $connectionType         Connection type for this listener
+        */
+       public function getConnectionType () {
+               $this->partialStub('Need to implement this method.') {
+       }
+
+       /**
+        * Getter for peer pool instance
+        *
+        * @return      $poolInstance   The peer pool instance we shall set
+        */
+       public function getPoolInstance () {
+               $this->partialStub('Need to implement this method.') {
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/main/interfaces/listener/.htaccess b/inc/main/interfaces/listener/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/main/interfaces/listener/class_Listenable.php b/inc/main/interfaces/listener/class_Listenable.php
new file mode 100644 (file)
index 0000000..d453324
--- /dev/null
@@ -0,0 +1,85 @@
+<?php
+/**
+ * An interface for listeners
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface Listenable extends FrameworkInterface {
+       /**
+        * Initializes the listener by setting up the required socket server
+        *
+        * @return      void
+        */
+       function initListener();
+
+       /**
+        * "Listens" for incoming network packages
+        *
+        * @return      void
+        */
+       function doListen();
+
+       /**
+        * Checks whether the listener would accept the given package data array
+        *
+        * @param       $packageData    Raw package data
+        * @return      $accepts                Whether this listener does accept
+        */
+       function ifListenerAcceptsPackageData (array $packageData);
+
+       /**
+        * Monitors incoming raw data from the handler and transfers it to the
+        * given receiver instance.
+        *
+        * @return      void
+        */
+       function monitorIncomingRawData ();
+
+       /**
+        * Getter for listen address
+        *
+        * @return      $listenAddress  The address this listener should listen on
+        */
+       function getListenAddress ();
+
+       /**
+        * Getter for listen port
+        *
+        * @return      $listenPort             The port this listener should listen on
+        */
+       function getListenPort ();
+
+       /**
+        * Getter for connection type
+        *
+        * @return      $connectionType         Connection type for this listener
+        */
+       function getConnectionType ();
+
+       /**
+        * Getter for peer pool instance
+        *
+        * @return      $poolInstance   The peer pool instance we shall set
+        */
+       function getPoolInstance ();
+}
+
+// [EOF]
+?>
diff --git a/todo-builder.sh b/todo-builder.sh
deleted file mode 100755 (executable)
index 295b6ba..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-
-# This script helps building the file docs/TODOs.txt and should be executed by
-# developers with SVN write-access
-
-if ! test -e "docs"; then
-  echo "$0: Please execute this script from root directory."
-  exit 1
-fi
-
-echo "$0: Generating TODOs.txt..."
-echo "### WARNING: THIS FILE IS AUTO-GENERATED BY $0 ###" > docs/TODOs.txt
-echo "### DO NOT EDIT THIS FILE. ###" >> docs/TODOs.txt
-find -type f -name "*.php" -exec grep -Hin "@TODO" {} \; | sort >> docs/TODOs.txt
-echo "### ### DEPRECATION FOLLOWS: ### ###" >> docs/TODOs.txt
-find -type f -name "*.php" -exec grep -Hin "@DEPRECATED" {} \; | sort >> docs/TODOs.txt
-echo "$0: Done."
-exit 0
diff --git a/update_year.sh b/update_year.sh
deleted file mode 100755 (executable)
index 062ef54..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-# Really lame ...
-find */ -type f -print0 | xargs -0 sed -i 's/2014 Core/2015 Core/g'