From: Roland 'Quix0r' Haeder Date: Tue, 11 Feb 2014 21:38:16 +0000 (+0100) Subject: Added DHT recipient discovery interface (wrong computer :-( ). X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e4d5c1fc75d9a717eaf4530f2c9ec0731f917108;p=hub.git Added DHT recipient discovery interface (wrong computer :-( ). Signed-off-by: Roland 'Quix0r' Haeder --- diff --git a/application/hub/config.php b/application/hub/config.php index 7f734fe38..316f6188d 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -660,12 +660,15 @@ $cfg->setConfigEntry('socket_registry_class', 'SocketRegistry'); // CFG: SOCKET-CONTAINER-CLASS $cfg->setConfigEntry('socket_container_class', 'SocketContainer'); -// CFG: PACKAGE-RECIPIENT-DISCOVERY +// CFG: PACKAGE-RECIPIENT-DISCOVERY-CLASS $cfg->setConfigEntry('package_recipient_discovery_class', 'PackageRecipientDiscovery'); -// CFG: SOCKET-DISCOVERY +// CFG: SOCKET-DISCOVERY-CLASS $cfg->setConfigEntry('socket_discovery_class', 'PackageSocketDiscovery'); +// CFG: DHT-RECIPIENT-DISCOVERY-CLASS +$cfg->setConfigEntry('dht_recipient_discovery_class', 'DhtRecipientDiscovery'); + // CFG: RECIPIENT-LIST-CLASS $cfg->setConfigEntry('recipient_list_class', 'RecipientList'); diff --git a/application/hub/interfaces/discovery/class_DiscoverableDhtRecipient.php b/application/hub/interfaces/discovery/class_DiscoverableDhtRecipient.php new file mode 100644 index 000000000..f1c686441 --- /dev/null +++ b/application/hub/interfaces/discovery/class_DiscoverableDhtRecipient.php @@ -0,0 +1,35 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core 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 . + */ +interface DiscoverableDhtRecipient extends FrameworkInterface { + /** + * Resolves one or more recipients for a DHT transfer by given package data. + * + * @param $packageData Valid package data array + * @return $recipients An indexed array with DHT recipients + */ + function resolveRecipientsByPackageData (array $packageData); +} + +// [EOF] +?> diff --git a/application/hub/interfaces/discovery/class_DiscoverableNodeRecipient.php b/application/hub/interfaces/discovery/class_DiscoverableNodeRecipient.php new file mode 100644 index 000000000..9ec820615 --- /dev/null +++ b/application/hub/interfaces/discovery/class_DiscoverableNodeRecipient.php @@ -0,0 +1,57 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core 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 . + */ +interface DiscoverableNodeRecipient extends FrameworkInterface, IteratorAggregate { + /** + * Tries to discover all recipients for given package data + * + * @param $packageData Raw package data array + * @return void + */ + function discoverRecipients (array $packageData); + + /** + * Tries to discover all recipients by given decoded package data. + * + * @param $decodedData Raw raw package data array + * @return void + */ + function discoverRawRecipients (array $decodedData); + + /** + * "Getter" for recipient iterator + * + * @return $iteratorInstance An instance of a Iterateable object + */ + function getIterator (); + + /** + * Clears all recipients for e.g. another package to deliver + * + * @return void + */ + function clearRecipients (); +} + +// [EOF] +?> diff --git a/application/hub/interfaces/discovery/class_DiscoverableRecipient.php b/application/hub/interfaces/discovery/class_DiscoverableRecipient.php deleted file mode 100644 index d7c2e43b0..000000000 --- a/application/hub/interfaces/discovery/class_DiscoverableRecipient.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core 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 . - */ -interface DiscoverableRecipient extends FrameworkInterface, IteratorAggregate { - /** - * Tries to discover all recipients for given package data - * - * @param $packageData Raw package data array - * @return void - */ - function discoverRecipients (array $packageData); - - /** - * Tries to discover all recipients by given decoded package data. - * - * @param $decodedData Raw raw package data array - * @return void - */ - function discoverRawRecipients (array $decodedData); - - /** - * "Getter" for recipient iterator - * - * @return $iteratorInstance An instance of a Iterateable object - */ - function getIterator (); - - /** - * Clears all recipients for e.g. another package to deliver - * - * @return void - */ - function clearRecipients (); -} - -// [EOF] -?> diff --git a/application/hub/main/discovery/dht/.htaccess b/application/hub/main/discovery/dht/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/discovery/dht/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/discovery/dht/class_DhtRecipientDiscovery.php b/application/hub/main/discovery/dht/class_DhtRecipientDiscovery.php new file mode 100644 index 000000000..732e8ee84 --- /dev/null +++ b/application/hub/main/discovery/dht/class_DhtRecipientDiscovery.php @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core 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 . + */ +class DhtRecipientDiscovery extends BaseHubDiscovery implements DiscoverableNodeRecipient, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create an instance of this class + * + * @return $discoveryInstance An instance of this discovery class + */ + public static final function createDhtRecipientDiscovery () { + // Get an instance of this class + $discoveryInstance = new DhtRecipientDiscovery(); + + // Return the prepared instance + return $discoveryInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/discovery/package/class_PackageRecipientDiscovery.php b/application/hub/main/discovery/package/class_PackageRecipientDiscovery.php index bea97ed06..3530eaaa3 100644 --- a/application/hub/main/discovery/package/class_PackageRecipientDiscovery.php +++ b/application/hub/main/discovery/package/class_PackageRecipientDiscovery.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class PackageRecipientDiscovery extends BaseHubDiscovery implements DiscoverableRecipient, Registerable { +class PackageRecipientDiscovery extends BaseHubDiscovery implements DiscoverableNodeRecipient, Registerable { /** * Protected constructor *