From edbd763708b1d8a901eccca9bf01888db99db2d6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 30 Oct 2011 21:32:01 +0000 Subject: [PATCH] Some minor improvements and important initialization of variables (opps) --- .../factories/states/peer/class_PeerStateFactory.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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); -- 2.39.5