* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class HubAnnouncementHelper extends BaseHubHelper implements HelpableHub {
- /**
- * An array with all tags for network packages
- */
- private $packageTags = array('announcement');
-
/**
* Protected constructor
*
// Set recipient type
$this->setRecipientType(NetworkPackage::NETWORK_TARGET_UPPER_NODES);
+
+ // Set package tags
+ $this->setPackageTags(array('announcement'));
}
/**
// Next, feed the content in. The network package class is a pipe-through class.
$packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP);
}
-
- /**
- * Getter for package tags in a simple array
- *
- * @return $tags An array with all tags for the currently handled package
- */
- public final function getPackageTags () {
- return $this->packageTags;
- }
}
// [EOF]
*/
private $messageData = array();
- /**
- * Package tags
- */
- private $packageTags = array();
-
-
/**
* Protected constructor
*
public final function getMessageData () {
return $this->messageData;
}
-
- /**
- * Getter for package tags in a simple array
- *
- * @return $packageTags An array with all tags for the currently handled package
- */
- public final function getPackageTags () {
- return $this->packageTags;
- }
-
- /**
- * Setter for package tags in a simple array
- *
- * @param $packageTags An array with all tags for the currently handled package
- * @return void
- */
- public final function setPackageTags (array $packageTags) {
- $this->packageTags = $packageTags;
- }
}
// [EOF]
$packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
// Next, feed the content in. The network package class is a pipe-through class.
- $packageInstance->enqueueRawDataFromTemplate($this);
+ $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_|||);
}
}
*/
private $recipientType = 'invalid';
+ /**
+ * Package tags
+ */
+ private $packageTags = array();
+
/**
* Protected constructor
*
public final function getRecipientType () {
return $this->recipientType;
}
+
+ /**
+ * Getter for package tags in a simple array
+ *
+ * @return $packageTags An array with all tags for the currently handled package
+ */
+ public final function getPackageTags () {
+ return $this->packageTags;
+ }
+
+ /**
+ * Setter for package tags in a simple array
+ *
+ * @param $packageTags An array with all tags for the currently handled package
+ * @return void
+ */
+ public final function setPackageTags (array $packageTags) {
+ $this->packageTags = $packageTags;
+ }
}
// [EOF]
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class HubSelfConnectHelper extends BaseHubHelper implements HelpableHub {
- /**
- * Package tags
- */
- private $packageTags = array('self_connect');
-
/**
* Protected constructor
*
// Set recipient type
$this->setRecipientType(NetworkPackage::NETWORK_TARGET_SELF);
+
+ // Set package tags
+ $this->setPackageTags(array('self_connect'));
}
/**
// Next, feed the content in. The network package class is a pipe-through class.
$packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP);
}
-
- /**
- * Getter for package tags in a simple array
- *
- * @return $tags An array with all tags for the currently handled package
- */
- public final function getPackageTags () {
- return $this->packageTags;
- }
}
// [EOF]
// Set recipient type
$this->setRecipientType(NetworkPackage::NETWORK_TARGET_UPPER_NODES);
+
+ // Set package tags
+ $this->setPackageTags(array('request_node_list'));
}
/**
*/
public function sendPackage (NodeHelper $nodeInstance) {
// Sanity check: Is the node in the approx. state? (active)
- $nodeInstance->getStateInstance()->validateNodeStateIsActive();
+ $nodeInstance->getStateInstance()->validateNodeStateIsAnnouncementCompleted();
// Compile the template, this inserts the loaded node data into the gaps.
$this->getTemplateInstance()->compileTemplate();
$packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
// Next, feed the content in. The network package class is a pipe-through class.
- $packageInstance->enqueueRawDataFromTemplate($this);
+ $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP);
}
}
throw new InvalidStateException($this, self::EXCEPTION_INVALID_STATE);
} // END - if
}
+
+ /**
+ * Validates if the state is 'announcement_completed' or throws an
+ * exception if it is every other state.
+ *
+ * @return void
+ * @throws InvalidStateException If the state is not 'active' and not 'announced'
+ */
+ public function validateNodeStateIsAnnouncementCompleted () {
+ // Just compare it...
+ if (!$this instanceof NodeAnnouncementCompletedState) {
+ // Throw the exception
+ throw new InvalidStateException($this, self::EXCEPTION_INVALID_STATE);
+ } // END - if
+ }
}
// [EOF]
<!-- The recipient type for this type of object //-->
<object-recipient-type>hub</object-recipient-type>
</object-list-entry>
+ <!-- A single object type we want to share. //-->
+ <object-list-entry>
+ <!-- The actual name, this must be the same as tag names are. //-->
+ <object-name>request_node_list</object-name>
+ <!-- Recipient limitation //-->
+ <object-recipient-limitation>upper</object-recipient-limitation>
+ <!-- Maximum spread of the object //-->
+ <object-max-spread>1</object-max-spread>
+ <!-- The protocol we should use for transmission //-->
+ <object-protocol>tcp</object-protocol>
+ <!-- The recipient type for this type of object //-->
+ <object-recipient-type>hub</object-recipient-type>
+ </object-list-entry>
</object-list>
</object-registry>