* @param $connectionType Type of connection, can only be 'incoming', 'outgoing' or 'server'
* @return void
* @throws InvalidSocketException If the given resource is invalid or errorous
+ * @throws InvalidConnectionTypeException If the provided connection type is not valid
*/
function addPeer ($socketResource, $connectionType);
// Some new peers found?
if ($left < 1) {
+ // Debug message
+ //* EXTREME-NOISY-DEBUG: */ $this->debugOutput('TCP-LISTENER: left=' . $left . ',server=' . $this->getSocketResource() . ',readers=' . print_r($readers, true));
+
// Nothing new found
return;
} // END - if
+ // Debug message
+ /* NOISY-DEBUG: */ $this->debugOutput('TCP-LISTENER:server=' . $this->getSocketResource() . ',readers=' . print_r($readers, true));
+
// Do we have changed peers?
if (in_array($this->getSocketResource(), $readers)) {
/*
$newSocket = socket_accept($this->getSocketResource());
// Debug message
- //* NOISY-DEBUG: */ $this->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: newSocket=' . $newSocket . ',server=' .$this->getSocketResource());
+ /* NOISY-DEBUG: */ $this->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: newSocket=' . $newSocket . ',server=' .$this->getSocketResource());
// Array for timeout settings
$options = array(
} elseif ((is_array($entry)) && (isset($entry['id']))) {
// Supported array found
$entry2 = crc32($entry['id']) . ':' . count($entry);
+ } elseif ((is_array($entry)) && (isset($entry[BasePool::SOCKET_ARRAY_RESOURCE])) && (isset($entry[BasePool::SOCKET_ARRAY_CONN_TYPE]))) {
+ // Is a socket resource array
+ $entry2 = crc32($entry[BasePool::SOCKET_ARRAY_RESOURCE] . ':' . $entry[BasePool::SOCKET_ARRAY_CONN_TYPE]);
+ } elseif (is_array($entry)) {
+ // Is a generic array
+ $entry2 = gettype($entry) . ':' . count($entry);
} else {
// Unsupported type detected
- $this->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: entry type ' . gettype($entry) . ' is unsupported.');
+ $this->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: Entry type ' . gettype($entry) . ' is unsupported.');
// @TODO Extend this somehow?
$entry2 = gettype($entry);
*
* @param $group Name of the pool group
* @param $poolSegment Name of the pool segment
- * @param $instance An instance of a class we should add to the pool
+ * @param $instance An instance of a class that should bed added to the pool
* @return void
*/
protected final function addInstance ($group, $poolName, Visitable $instance) {
/**
* Adds an entry to the pool
*
- * @param $poolEntry The new pool entry we should add
+ * @param $poolEntry The new pool entry that should be added
* @return void
*/
protected final function addPoolEntry ($poolEntry) {
* @param $connectionType Type of connection, can only be 'incoming', 'outgoing' or 'server'
* @return void
* @throws InvalidSocketException If the given resource is invalid or errorous
+ * @throws InvalidConnectionTypeException If the provided connection type is not valid
*/
public function addPeer ($socketResource, $connectionType) {
+ // Debug message
+ //* NOISY-DEBUG: */ $this->debugOutput(__METHOD__ . ': socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',connectionType=' . $connectionType . ' - ENTERED!');
+
// Validate the socket
$this->validateSocket($socketResource);
+ // Is the connection type valid?
+ if (!$this->isValidConnectionType($connectionType)) {
+ // Is not a valid connection type!
+ throw new InvalidConnectionTypeException(array($this, $connectionType), self::EXCEPTION_INVALID_CONNECTION_TYPE);
+ } // END - if
+
// Default is this peer's IP
$peerName = '0.0.0.0';
}
// Debug message
- $this->debugOutput('POOL: Adding peer ' . $peerName . ',socketResource=' . $socketResource);
+ $this->debugOutput('POOL: Adding peer ' . $peerName . ',socketResource=' . $socketResource . ',type=' . $connectionType);
// Construct the array
$socketArray = array(