* - listen-port (TCP/UDP listen port for inbound connections)
*
* @param $messageArray An array with all minimum message data
- * @param $handlerInstance An instance of a HandleableMessage class
+ * @param $handlerInstance An instance of a Handleable class
+ * @param $forceUpdate Optionally force update, don't register (default: register if not found)
* @return void
+ * @throws NodeSessionIdVerficationException If the node was not found and update is forced
*/
- public function registerNodeByMessageData (array $messageData, HandleableMessage $handlerInstance) {
+ public function registerNodeByMessageData (array $messageData, Handleable $handlerInstance, $forceUpdate = FALSE) {
// Get a search criteria class
$searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
if ($resultInstance->next()) {
// Entry found, so update it
$this->getWrapperInstance()->updateNodeByMessageData($messageData, $handlerInstance, $searchInstance);
- } else {
+ } elseif ($forceUpdate === FALSE) {
// Nothing found, so register it
$this->getWrapperInstance()->registerNodeByMessageData($messageData, $handlerInstance);
+ } else {
+ /*
+ * Do not register non-existent nodes here. This is maybe fatal,
+ * caused by "stolen" session id and/or not matching IP
+ * number/port combination.
+ */
+ throw new NodeSessionIdVerficationException(array($this, $messageData), BaseHubSystem::EXCEPTION_NODE_SESSION_ID_NOT_VERIFYING);
}
// Save last exception