]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/pools/class_BasePool.php
Now incoming, outgoing and 'server' pools are possible
[hub.git] / application / hub / main / pools / class_BasePool.php
index b15cfd2641cd7977727d71322a78bae5e742e528..ca2243d4913ccae0c7a24de9f307cdfd3af455ec 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 class BasePool extends BaseHubSystem implements Visitable {
+       /**
+        * Socket array elements
+        */
+       const SOCKET_ARRAY_RESOURCE  = 'resource';
+       const SOCKET_ARRAY_CONN_TYPE = 'connection_type';
+
        /**
         * A list of pool entries
         */
        private $poolEntriesInstance = NULL;
 
+       /**
+        * An array with all valid connection types
+        */
+       private $connectionTypes = array();
+
        /**
         * Protected constructor
         *
@@ -39,6 +50,13 @@ class BasePool extends BaseHubSystem implements Visitable {
 
                // Init the pool entries
                $this->poolEntriesInstance = ObjectFactory::createObjectByConfiguredName('pool_entries_list_class');
+
+               // Init array of connection types
+               $this->connectionTypes = array(
+                       BaseConnectionHelper::CONNECTION_TYPE_INCOMING,
+                       BaseConnectionHelper::CONNECTION_TYPE_OUTGOING,
+                       BaseConnectionHelper::CONNECTION_TYPE_SERVER
+               );
        }
 
        /**
@@ -143,6 +161,20 @@ class BasePool extends BaseHubSystem implements Visitable {
                // Return it
                return $array;
        }
+
+       /**
+        * Checks whether the given connection type is valid
+        *
+        * @param       $connectionType         Type of connection, can be 'incoming', 'outgoing' or 'server'
+        * @return      $isValid                        Whether the provided connection type is valid
+        */
+       protected function isValidConnectionType ($connectionType) {
+               // Is it valid?
+               $isValid = in_array($connectionType, $this->connectionTypes, true);
+
+               // Return result
+               return $isValid;
+       }
 }
 
 // [EOF]