* @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();
$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);
}
// 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);
$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);