From: Roland Häder Date: Sun, 30 Oct 2011 21:32:01 +0000 (+0000) Subject: Some minor improvements and important initialization of variables (opps) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=edbd763708b1d8a901eccca9bf01888db99db2d6;p=hub.git Some minor improvements and important initialization of variables (opps) --- diff --git a/application/hub/main/factories/states/peer/class_PeerStateFactory.php b/application/hub/main/factories/states/peer/class_PeerStateFactory.php index 72989dc6c..5fa84f337 100644 --- a/application/hub/main/factories/states/peer/class_PeerStateFactory.php +++ b/application/hub/main/factories/states/peer/class_PeerStateFactory.php @@ -66,6 +66,9 @@ class PeerStateFactory extends ObjectFactory { * @return $stateInstance A Stateable class instance */ public static final function createPeerStateInstanceBySocketStatusCode (ConnectionHelper $helperInstance, array $packageData, $socketResource, $errorCode) { + // Init state instance, this is better coding practice + $stateInstance = NULL; + // So first we need our lookup table $tableInstance = self::getTableInstance(); @@ -74,13 +77,13 @@ class PeerStateFactory extends ObjectFactory { $tableInstance->purgeOldEntriesBySocketResource($socketResource); } catch (InvalidSocketException $e) { // Just log all errors - $tableInstance->debugOutput('PEER-STATE-FACTORY: Purging of old entries failed. Message from exception: ' . $e->getMessage()); + $tableInstance->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ']: Purging of old entries failed. Message from exception: ' . $e->getMessage()); } // Do we have an entry? if ($tableInstance->isSenderNewPeer($packageData)) { // Debug output - $tableInstance->debugOutput('PEER-STATE-FACTORY: errorCode=' . $errorCode); + $tableInstance->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ']: errorCode=' . $errorCode); // Register the new peer with its session id $tableInstance->registerPeerByPackageData($packageData, $socketResource); @@ -99,7 +102,7 @@ class PeerStateFactory extends ObjectFactory { } // Debug message - $stateInstance->debugOutput('PEER-STATE[' . __LINE__ . ']: Has changed from ' . $helperInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); + $stateInstance->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ']: Peer state has changed from ' . $helperInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); // Set the state in the helper $helperInstance->setStateInstance($stateInstance); @@ -124,7 +127,7 @@ class PeerStateFactory extends ObjectFactory { $stateInstance = self::createObjectByConfiguredName($className, array($helperInstance)); // Debug message - $stateInstance->debugOutput('PEER-STATE[' . __LINE__ . ']: Has changed from ' . $helperInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . ' (' . $stateInstance->__toString() . ').'); + $stateInstance->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ']: Peer state has changed from ' . $helperInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . ' (' . $stateInstance->__toString() . ').'); // Once we have that state, set it in the peer instance $helperInstance->setStateInstance($stateInstance);