*/
public function ifAddressMatches ($unl) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: unl=%s - CALLED!', strtoupper($this->getSocketProtocol()), $unl));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: unl=%s - CALLED!', strtoupper($this->getSocketProtocol()), $unl));
// Get current package data
$packageData = $this->getPackageData();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: unl=' . $unl . ',packageData=' . print_r($packageData, true));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: unl=' . $unl . ',packageData=' . print_r($packageData, true));
// So, does both match?
$matches = ((isset($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])) && ($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] === $unl));
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: matches=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($matches)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: matches=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($matches)));
// Return result
return $matches;
*/
public function ifSocketResourceMatches ($socketResource) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: socketResource[' . gettype($socketResource) . ']=' .$socketResource . ',storedResource[' . gettype($this->getSocketResource()) . ']=' . $this->getSocketResource());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: socketResource[' . gettype($socketResource) . ']=' .$socketResource . ',storedResource[' . gettype($this->getSocketResource()) . ']=' . $this->getSocketResource());
// So, does both match?
$matches = ((is_resource($socketResource)) && ($socketResource === $this->getSocketResource()));
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: matches=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($matches)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: matches=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($matches)));
// Return result
return $matches;
$this->accept($visitorInstance);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: EXIT!');
}
/**
$this->accept($visitorInstance);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: EXIT!');
}
/**
*/
public function getSocketPeerName (&$peerAddress, &$peerPort) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: peerAddress=%s,peerPort=%d - CALLED!', strtoupper($this->getSocketProtocol()), $peerAddress, $peerPort));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: peerAddress=%s,peerPort=%d - CALLED!', strtoupper($this->getSocketProtocol()), $peerAddress, $peerPort));
// Should be valid socket
if (!$this->isValidSocket()) {
}
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: peerAddress=%s,peerPort=%d,result[%s]=%d - EXIT!', strtoupper($this->getSocketProtocol()), $peerAddress, $peerPort, gettype($result), intval($result)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: peerAddress=%s,peerPort=%d,result[%s]=%d - EXIT!', strtoupper($this->getSocketProtocol()), $peerAddress, $peerPort, gettype($result), intval($result)));
// Return result
return $result;
*/
public function getSocketRecipient () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
// Should be valid socket
if (!$this->isValidSocket()) {
} // END - if
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: packageData[%s]=%s - EXIT!', strtoupper($this->getSocketProtocol()), NetworkPackage::PACKAGE_DATA_RECIPIENT, $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: packageData[%s]=%s - EXIT!', strtoupper($this->getSocketProtocol()), NetworkPackage::PACKAGE_DATA_RECIPIENT, $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
// Return it
return $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT];
*/
public function getSocketRecipientAddress () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
// Should be valid socket
if (!$this->isValidSocket()) {
$recipientAddress = $unlInstance->getUnlAddress();
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: recipientAddress=%s - EXIT!', strtoupper($this->getSocketProtocol()), $recipientAddress));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: recipientAddress=%s - EXIT!', strtoupper($this->getSocketProtocol()), $recipientAddress));
// Return it
return $recipientAddress;
*/
public function getSocketRecipientPort () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
// Should be valid socket
if (!$this->isValidSocket()) {
$recipientPort = $unlInstance->getUnlPort();
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: recipientPort=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($recipientPort)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: recipientPort=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($recipientPort)));
// Return it
return $recipientPort;
*/
public function isValidSocket () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
// Get socket resource
$socketResource = $this->getSocketResource();
$isValidSocket = (is_resource($socketResource));
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: isValidSocket=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($isValidSocket)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: isValidSocket=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($isValidSocket)));
// Return status
return $isValidSocket;
*/
public function getLastSocketErrorCode () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
// Should be valid socket
if (!$this->isValidSocket()) {
$errorCode = socket_last_error($socketResource);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: errorCode=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($errorCode)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: errorCode=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($errorCode)));
// Return it
return $errorCode;
*/
public function getLastSocketErrorMessage () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
// Should be valid socket
if (!$this->isValidSocket()) {
*/
public function translateLastSocketErrorCodeToName () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
// Get last error code
$errorCode = $this->getLastSocketErrorCode();
$codeName = $this->translateSocketErrorCodeToName($errorCode);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: codeName=%s - EXIT!', strtoupper($this->getSocketProtocol()), $codeName));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: codeName=%s - EXIT!', strtoupper($this->getSocketProtocol()), $codeName));
// Return it
return $codeName;
*/
public function bindSocketTo ($bindAddress, $bindPort = 0) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
// Should be valid socket
if (!$this->isValidSocket()) {
$result = socket_bind($this->getSocketResource(), $bindAddress, $bindPort);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result)));
// Return result
return $result;
*/
public function listenToSocket () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
// Should be valid socket
if (!$this->isValidSocket()) {
$result = socket_listen($this->getSocketResource());
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result)));
// Return result
return $result;
*/
public function enableSocketNonBlocking () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
// Should be valid socket
if (!$this->isValidSocket()) {
$result = socket_set_nonblock($this->getSocketResource());
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result)));
// Return result
return $result;
*/
public function enableSocketReuseAddress () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
// Should be valid socket
if (!$this->isValidSocket()) {
$result = $this->setSocketOption(SOL_SOCKET, SO_REUSEADDR, 1);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result)));
// Return result
return $result;
*/
public function connectToSocketRecipient () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
// Should be valid socket
if (!$this->isValidSocket()) {
$unlRecipient = $this->getSocketRecipient();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: unlRecipient=%s', strtoupper($this->getSocketProtocol()), $unlRecipient));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: unlRecipient=%s', strtoupper($this->getSocketProtocol()), $unlRecipient));
// Create UNL instance from it. This will validate the connection
$unlInstance = UniversalNodeLocatorFactory::createUnlInstanceFromString($unlRecipient);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: unlAddress=%s,unlPort=%d', strtoupper($this->getSocketProtocol()), $unlInstance->getUnlAddress(), $unlInstance->getUnlPort()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: unlAddress=%s,unlPort=%d', strtoupper($this->getSocketProtocol()), $unlInstance->getUnlAddress(), $unlInstance->getUnlPort()));
// Try to connect to it
$result = socket_connect($this->getSocketResource(), $unlInstance->getUnlAddress(), $unlInstance->getUnlPort());
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result)));
// Return result
return $result;
*/
public function doShutdown () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
// Should be valid socket
if (!$this->isValidSocket()) {
$this->markConnectionShuttedDown();
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: EXIT!');
}
/**
*/
public function isValidConnectionType ($connectionType) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: connectionType=%d - CALLED!', strtoupper($this->getSocketProtocol()), $connectionType));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: connectionType=%d - CALLED!', strtoupper($this->getSocketProtocol()), $connectionType));
// Is it valid?
$isValid = in_array($connectionType, $this->connectionTypes, TRUE);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: isValid=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($isValid)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: isValid=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($isValid)));
// Return result
return $isValid;
*/
public function acceptNewIncomingSocket () {
// Trace message
- /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
+ //* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
// Should be valid socket
if (!$this->isValidSocket()) {
} // END - if
// Debug message
- /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s', strtoupper($this->getSocketProtocol()), $this->getSocketResource()));
+ //* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s', strtoupper($this->getSocketProtocol()), $this->getSocketResource()));
// Init all arrays, at least readers
$readers = array($this->getSocketResource());
$excepts = array();
// Trace message
- /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Calling socket_select(%d,%d,%d,0%d) ...', strtoupper($this->getSocketProtocol()), count($readers), count($writers), count($excepts), $this->socketSelectTimeout));
+ //* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Calling socket_select(%d,%d,%d,0%d) ...', strtoupper($this->getSocketProtocol()), count($readers), count($writers), count($excepts), $this->socketSelectTimeout));
// Check if we have some peers left
$left = socket_select(
);
// Debug message
- /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: left=%d,readers()=%d,writers()=%d,except()=%d) ...', strtoupper($this->getSocketProtocol()), $left, count($readers), count($writers), count($excepts)));
+ //* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: left=%d,readers()=%d,writers()=%d,except()=%d) ...', strtoupper($this->getSocketProtocol()), $left, count($readers), count($writers), count($excepts)));
// Some new peers found?
if ($left < 1) {
} // END - if
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: serverSocket=' . $this->getSocketResource() . ',readers=' . print_r($readers, true));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: serverSocket=' . $this->getSocketResource() . ',readers=' . print_r($readers, true));
// Do we have changed peers?
if (!in_array($this->getSocketResource(), $readers)) {
$socketResource = socket_accept($this->getSocketResource());
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: socketResource=' . $socketResource . ',serverSocket=' .$this->getSocketResource());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: socketResource=' . $socketResource . ',serverSocket=' .$this->getSocketResource());
// Create socket instance from it
$socketInstance = SocketFactory::createIncomingSocketInstance($socketResource, $this->getSocketProtocol());
} // END - if
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result)));
// Return result
return $result;
*/
public function setSocketTimeoutOptions () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
// Array for timeout settings
$options = array(
$result = $this->setSocketOption(SOL_SOCKET, SO_RCVTIMEO, $options);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result)));
// Return result
return $result;
*/
public function enableSocketOutOfBandData () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
- $this->partialStub('Please implement this method.');
+ // Call inner method
+ $result = $this->setSocketOption(SOL_SOCKET, SO_OOBINLINE, 1);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result)));
+
+ // Return result
+ return $result;
}
/**
*/
public function clearLastSocketError () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Clearing socket error - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Clearing socket error - CALLED!');
// Should be valid socket
if (!$this->isValidSocket()) {
socket_clear_error($this->getSocketResource());
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Error cleared - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Error cleared - EXIT!');
}
/**
*/
public function registerInfoInstance (ShareableInfo $infoInstance) {
// Trace message
- /* NOSY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Calling infoInstance->getListenerInstance() - CALLED!', strtoupper($this->getSocketProtocol())));
+ //* NOSY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Calling infoInstance->getListenerInstance() - CALLED!', strtoupper($this->getSocketProtocol())));
// Get listener/helper from info class
$listenerInstance = $infoInstance->getListenerInstance();
$helperInstance = $infoInstance->getHelperInstance();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: listenerInstance[]=' . gettype($listenerInstance) . ',helperInstance[]=' . gettype($helperInstance));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: listenerInstance[]=' . gettype($listenerInstance) . ',helperInstance[]=' . gettype($helperInstance));
// Is there a listener instance set?
if ($listenerInstance instanceof Listenable) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Setting listenerInstance=' . $listenerInstance->__toString() . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Setting listenerInstance=' . $listenerInstance->__toString() . ' ...');
// Set it here for later usage
$this->setListenerInstance($listenerInstance);
} elseif ($helperInstance instanceof ConnectionHelper) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Setting helperInstance=' . $helperInstance->__toString() . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Setting helperInstance=' . $helperInstance->__toString() . ' ...');
// Set it here for later usage
$this->setHelperInstance($helperInstance);
}
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: EXIT!');
}
/**
*/
public function writeBufferToSocketByArray (array &$socketBuffer, &$sentBytes) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketBuffer()=%d,sentBytes=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketBuffer), $sentBytes));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketBuffer()=%d,sentBytes=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketBuffer), $sentBytes));
// Should be valid socket
if (!$this->isValidSocket()) {
}
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Sending out %d bytes,rawBufferSize=%d,diff=%d to socketResource=%s', strtoupper($this->getSocketProtocol()), strlen($socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA]), $socketBuffer[NetworkPackage::RAW_INDEX_BUFFER_SIZE], $socketBuffer[NetworkPackage::RAW_INDEX_DIFF], $this->getSocketResource()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Sending out %d bytes,rawBufferSize=%d,diff=%d to socketResource=%s', strtoupper($this->getSocketProtocol()), strlen($socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA]), $socketBuffer[NetworkPackage::RAW_INDEX_BUFFER_SIZE], $socketBuffer[NetworkPackage::RAW_INDEX_DIFF], $this->getSocketResource()));
// Is some data still pending or sent all out?
if ($socketBuffer[NetworkPackage::RAW_INDEX_DIFF] >= 0) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: MD5=%s', strtoupper($this->getSocketProtocol()), md5(substr($socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA], 0, ($socketBuffer[NetworkPackage::RAW_INDEX_BUFFER_SIZE] - $socketBuffer[NetworkPackage::RAW_INDEX_DIFF])))));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: MD5=%s', strtoupper($this->getSocketProtocol()), md5(substr($socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA], 0, ($socketBuffer[NetworkPackage::RAW_INDEX_BUFFER_SIZE] - $socketBuffer[NetworkPackage::RAW_INDEX_DIFF])))));
// Send all out (encodedData is smaller than or equal buffer size)
$sentBytes = socket_write($this->getSocketResource(), $socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA], ($socketBuffer[NetworkPackage::RAW_INDEX_BUFFER_SIZE] - $socketBuffer[NetworkPackage::RAW_INDEX_DIFF]));
} else {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: MD5=%s', strtoupper($this->getSocketProtocol()), md5(substr($socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA], 0, $socketBuffer[NetworkPackage::RAW_INDEX_BUFFER_SIZE]))));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: MD5=%s', strtoupper($this->getSocketProtocol()), md5(substr($socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA], 0, $socketBuffer[NetworkPackage::RAW_INDEX_BUFFER_SIZE]))));
// Send buffer size out
$sentBytes = socket_write($this->getSocketResource(), $socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA], $socketBuffer[NetworkPackage::RAW_INDEX_BUFFER_SIZE]);
$result = ($sentBytes !== FALSE);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: sentBytes[%s]=%d,result=%d', strtoupper($this->getSocketProtocol()), gettype($sentBytes), $sentBytes, intval($result)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: sentBytes[%s]=%d,result=%d', strtoupper($this->getSocketProtocol()), gettype($sentBytes), $sentBytes, intval($result)));
// If there was an error, don't continue here
if ($result === FALSE) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socket_write() failed, please evalutate. - EXIT!', strtoupper($this->getSocketProtocol())));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socket_write() failed, please evalutate. - EXIT!', strtoupper($this->getSocketProtocol())));
// Failed delivery!
return FALSE;
} elseif (($sentBytes === 0) && (strlen($socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA]) > 0)) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: All sent, returning TRUE ... - EXIT!', strtoupper($this->getSocketProtocol())));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: All sent, returning TRUE ... - EXIT!', strtoupper($this->getSocketProtocol())));
// Nothing sent means all data has been sent
return TRUE;
$socketBuffer[NetworkPackage::RAW_INDEX_SENT_BYTES] += $sentBytes;
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Sent out %d of %d bytes ...', strtoupper($this->getSocketProtocol()), $sentBytes, strlen($socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA])));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Sent out %d of %d bytes ...', strtoupper($this->getSocketProtocol()), $sentBytes, strlen($socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA])));
// Cut out the last unsent bytes
$socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA] = substr($socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA], $sentBytes);
}
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result)));
// Return result
return $result;
*/
public function handleSocketError ($method, $line, array $socketData) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-SYSTEM: Handling socket errorCode=%d - CALLED!', $this->getLastSocketErrorCode()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-SYSTEM: Handling socket errorCode=%d - CALLED!', $this->getLastSocketErrorCode()));
// This method handles only socket resources
if (!$this->isValidSocket()) {
$this->clearLastSocketError();
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: EXIT!');
}
/**
*/
protected function getSocketErrorHandlerFromCode ($errorCode) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: errorCode=%d - CALLED!', strtoupper($this->getSocketProtocol()), $errorCode));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: errorCode=%d - CALLED!', strtoupper($this->getSocketProtocol()), $errorCode));
// Create a name from translated error code
$handlerName = 'handleSocketError' . self::convertToClassName($this->translateSocketErrorCodeToName($errorCode));
} // END - if
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: handlerName=%d - EXIT!', strtoupper($this->getSocketProtocol()), $handlerName));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: handlerName=%d - EXIT!', strtoupper($this->getSocketProtocol()), $handlerName));
// Return it
return $handlerName;
*/
protected function handleSocketErrorPermissionDenied (array $socketData) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData)));
// Get socket error code for verification
$socketError = $this->getLastSocketErrorCode();
*/
protected function handleSocketErrorConnectionTimedOut (array $socketData) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData)));
// Get socket error code for verification
$socketError = $this->getLastSocketErrorCode();
*/
protected function handleSocketErrorResourceUnavailable (array $socketData) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData)));
// Get socket error code for verification
$socketError = $this->getLastSocketErrorCode();
*/
protected function handleSocketErrorConnectionRefused (array $socketData) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData)));
// Get socket error code for verification
$socketError = $this->getLastSocketErrorCode();
*/
protected function handleSocketErrorNoRouteToHost (array $socketData) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData)));
// Get socket error code for verification
$socketError = $this->getLastSocketErrorCode();
*/
protected function handleSocketErrorOperationAlreadyProgress (array $socketData) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData)));
// Get socket error code for verification
$socketError = $this->getLastSocketErrorCode();
*/
protected function handleSocketErrorConnectionResetByPeer (array $socketData) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData)));
// Get socket error code for verification
$socketError = $this->getLastSocketErrorCode();
*/
protected function handleSocketErrorOperationNotSupported (array $socketData) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData)));
// Get socket error code for verification
$socketError = $this->getLastSocketErrorCode();
*/
protected function handleSocketErrorOperationInProgress (array $socketData) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData)));
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-HELPER: Operation is now in progress, this is usual for non-blocking connections and is no bug.');
}
*/
private function translateSocketErrorCodeToName ($errorCode) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: errorCode=%d - CALLED!', strtoupper($this->getSocketProtocol()), $errorCode));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: errorCode=%d - CALLED!', strtoupper($this->getSocketProtocol()), $errorCode));
// Nothing bad happened by default
$errorName = StorableSocket::SOCKET_CONNECTED;
} // END - switch
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: errorName=%d - EXIT!', strtoupper($this->getSocketProtocol()), $errorName));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: errorName=%d - EXIT!', strtoupper($this->getSocketProtocol()), $errorName));
// Return translated name
return $errorName;
*/
private function setSocketOption ($level, $optionName, $optionValue) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: level=%s,optionName=%s,optionValue[%s]=%s - CALLED!', strtoupper($this->getSocketProtocol()), $level, $optionName, gettype($optionValue), implode(',', $optionValue)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: level=%s,optionName=%s,optionValue[%s]=%s - CALLED!', strtoupper($this->getSocketProtocol()), $level, $optionName, gettype($optionValue), implode(',', $optionValue)));
// Should be valid socket
if (!$this->isValidSocket()) {
*/
private function prepareSearchInstance (array $nodeData) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
// Assert on array elements
assert(isset($nodeData[self::DB_COLUMN_NODE_ID]));
$searchInstance->setLimit(1);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
// Return it
return $searchInstance;
*/
private function prepareLocalDataSetInstance () {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
// Get node/request instances
$nodeInstance = NodeObjectFactory::createNodeInstance();
$dataSetInstance->addCriteria(self::DB_COLUMN_ACCEPT_BOOTSTRAP, $this->translateBooleanToYesNo($nodeInstance->isAcceptingDhtBootstrap()));
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
// Return it
return $dataSetInstance;
*/
public function isLocalNodeRegistered () {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
// Get a search criteria instance
$searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
$isRegistered = $resultInstance->valid();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: isRegistered=' . intval($isRegistered) . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: isRegistered=' . intval($isRegistered) . ' - EXIT!');
// Return result
return $isRegistered;
*/
public function registerLocalNode () {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
// Assert to make sure this method is called with no record in DB (the actual backend of the DHT)
assert(!$this->isLocalNodeRegistered());
$this->queryInsertDataSet($dataSetInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
}
/**
*/
public function updateLocalNode () {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
// Assert to make sure this method is called with one record in DB (the actual backend of the DHT)
assert($this->isLocalNodeRegistered());
$this->queryUpdateDataSet($dataSetInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
}
/**
*/
public function findNodeLocalBySessionId ($sessionId) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: sessionId=' . $sessionId . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: sessionId=' . $sessionId . ' - CALLED!');
// Get search criteria
$searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
$resultInstance = $this->doSelectByCriteria($searchInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: resultInstance->valid()=' . intval($resultInstance->valid()) . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: resultInstance->valid()=' . intval($resultInstance->valid()) . ' - EXIT!');
// Return result instance
return $resultInstance;
*/
public function registerNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: handlerInstance=' . $handlerInstance->__toString() . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: handlerInstance=' . $handlerInstance->__toString() . ' - CALLED!');
// Get a data set instance
$dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT));
$this->queryInsertDataSet($dataSetInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER - EXIT!');
}
/**
*/
public function updateNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance, LocalSearchCriteria $searchInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
// Get a data set instance
$dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT));
$this->queryUpdateDataSet($dataSetInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
}
/**
*/
public function isNodeRegistered (array $nodeData) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
// Assert on array elements
assert(isset($nodeData[self::DB_COLUMN_NODE_ID]));
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: node-id=' . $nodeData[self::DB_COLUMN_NODE_ID]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: node-id=' . $nodeData[self::DB_COLUMN_NODE_ID]);
// Get search criteria
$searchInstance = $this->prepareSearchInstance($nodeData);
$isRegistered = $resultInstance->valid();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: isRegistered=' . intval($isRegistered) . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: isRegistered=' . intval($isRegistered) . ' - EXIT!');
// Return registration status
return $isRegistered;
*/
public function registerNode (array $nodeData) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
// Assert on array elements
assert(isset($nodeData[self::DB_COLUMN_NODE_ID]));
$this->partialStub('nodeData=' . print_r($nodeData, TRUE));
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
}
/**
*/
public function updateNode (array $nodeData) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
// Assert on array elements
assert(isset($nodeData[self::DB_COLUMN_NODE_ID]));
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: Updating DHT entry for node-id=' . $nodeData[self::DB_COLUMN_NODE_ID] . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: Updating DHT entry for node-id=' . $nodeData[self::DB_COLUMN_NODE_ID] . ' ...');
// Is the node registered?
if (!$this->isNodeRegistered($nodeData)) {
$nodeInstance = NodeObjectFactory::createNodeInstance();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: nodeData=' . print_r($nodeData, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: nodeData=' . print_r($nodeData, TRUE));
// Add all array elements
$nodeInstance->addArrayToDataSet($dataSetInstance, $nodeData);
$this->queryUpdateDataSet($dataSetInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
}
/**
$hasUnpublished = $this->unpublishedEntriesInstance->valid();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
// Return it
return $hasUnpublished;
*/
public function initEntryPublication () {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
/*
* Make sure that hasUnpublishedEntries() has been called first by
$this->queryUpdateDataSet($dataSetInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
}
/**
*/
public function removeNonPublicDataFromArray(array $data) {
// Currently call only inner method
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: Calling parent::removeNonPublicDataFromArray(data) ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: Calling parent::removeNonPublicDataFromArray(data) ...');
$data = parent::removeNonPublicDataFromArray($data);
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: data[]=' . gettype($data));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: data[]=' . gettype($data));
// Return cleaned data
return $data;
*/
public function getResultFromExcludedSender (array $packageData) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
// Assert on required array field
assert(isset($packageData[NetworkPackage::PACKAGE_DATA_SENDER_ADDRESS]));
$resultInstance = $this->doSelectByCriteria($searchInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
// Return result instance
return $resultInstance;
*/
public function getResultFromKeyValue ($key, $value) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
// Get max recipients
$maxRecipients = $this->getConfigInstance()->getConfigEntry('max_dht_recipients');
$resultInstance = $this->doSelectByCriteria($searchInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
// Return result instance
return $resultInstance;
*/
public function removeNonPublicDataFromArray(array $data) {
// Currently call only inner method
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE-WRAPPER: Calling parent::removeNonPublicDataFromArray(data) ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE-WRAPPER: Calling parent::removeNonPublicDataFromArray(data) ...');
$data = parent::removeNonPublicDataFromArray($data);
// Return cleaned data
return $data;
}
-}
-// [EOF]
-?>
+}
*/
private function getSenderSearchInstanceFromPackageData (array $packageData) {
// Get the instance
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE-WRAPPER: Searching for sender ' . $packageData[NetworkPackage::PACKAGE_DATA_SENDER_ADDRESS]);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: Searching for sender ' . $packageData[NetworkPackage::PACKAGE_DATA_SENDER_ADDRESS]);
$searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
// Add 'sender' as the peer's IP address
*/
public function isSenderNewPeer (array $packageData, StoreableCriteria $dataSetInstance = NULL) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE-WRAPPER: ' . __FUNCTION__ . ' called with packageData()=' . count($packageData) . ' - CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: packageData()=' . count($packageData) . ' - CALLED!');
// Is the package valid?
if (!isset($packageData[NetworkPackage::PACKAGE_DATA_SENDER_ADDRESS])) {
$entries = $this->doSelectCountByCriteria($searchInstance, array(self::DB_COLUMN_PEER_SESSION_ID => TRUE));
// Is it there?
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE-WRAPPER: entries=' . $entries);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: entries=' . $entries);
$isNewPeer = ($entries != 1);
// Return the result
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE-WRAPPER: isNewPeer=' . intval($isNewPeer) . ' - EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: isNewPeer=' . intval($isNewPeer) . ' - EXIT!');
return $isNewPeer;
}
$this->queryInsertDataSet($dataSetInstance, array(self::DB_COLUMN_PEER_SESSION_ID => TRUE));
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE-WRAPPER: Peer ' . $packageData[NetworkPackage::PACKAGE_DATA_SENDER_ADDRESS] . ' has been registered.');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: Peer ' . $packageData[NetworkPackage::PACKAGE_DATA_SENDER_ADDRESS] . ' has been registered.');
}
/**
}
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE-WRAPPER: Peer ' . $packageData[NetworkPackage::PACKAGE_DATA_SENDER_ADDRESS] . ' has been registered/updated with state ' . $stateInstance->getStateName());
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: Peer ' . $packageData[NetworkPackage::PACKAGE_DATA_SENDER_ADDRESS] . ' has been registered/updated with state ' . $stateInstance->getStateName());
}
/**
*/
public function isSamePeerState (ConnectionHelper $helperInstance, array $packageData) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE-WRAPPER: State ' . $helperInstance->getPrintableState() . ' needs to be checked it has changed ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: State ' . $helperInstance->getPrintableState() . ' needs to be checked it has changed ...');
// Now get the search instance from given package data
$searchInstance = $this->getSenderSearchInstanceFromPackageData($packageData);
$rowData = $resultInstance->current();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE-WRAPPER: rowData[' . gettype($rowData) . ']=' . print_r($rowData, TRUE));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: rowData[' . gettype($rowData) . ']=' . print_r($rowData, TRUE));
// Assert on important elements
assert(isset($rowData[self::DB_COLUMN_PEER_STATE]));
$isSamePeerState = ($rowData[self::DB_COLUMN_PEER_STATE] == $helperInstance->getPrintableState());
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE-WRAPPER: state in database: ' . $rowData[self::DB_COLUMN_PEER_STATE] . ', new state: ' . $helperInstance->getPrintableState() . ',isSamePeerState=' . intval($isSamePeerState));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: state in database: ' . $rowData[self::DB_COLUMN_PEER_STATE] . ', new state: ' . $helperInstance->getPrintableState() . ',isSamePeerState=' . intval($isSamePeerState));
// Return it
return $isSamePeerState;
$unhandledDataLeft = (!$this->getHandlerInstance()->getStackInstance()->isStackEmpty(ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA));
// Return it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-DECODER: unhandledDataLeft=' . intval($unhandledDataLeft));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-DECODER: unhandledDataLeft=' . intval($unhandledDataLeft));
return $unhandledDataLeft;
}
$rawPackageContent = $this->getHandlerInstance()->getStackInstance()->popNamed(ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-DECODER: Got ' . strlen($rawPackageContent) . ' bytes from stack ' . ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA . ', decoding it ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-DECODER: Got ' . strlen($rawPackageContent) . ' bytes from stack ' . ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA . ', decoding it ...');
// "Decode" the raw package content by using the NetworkPackage instance
$decodedData = $this->getPackageInstance()->decodeRawContent($rawPackageContent);
);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-DECODER: decodedData(' . count($decodedData) . ')=' . print_r($decodedData, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-DECODER: decodedData(' . count($decodedData) . ')=' . print_r($decodedData, TRUE));
// Next get a recipient-discovery instance
$discoveryInstance = PackageDiscoveryFactory::createPackageDiscoveryInstance();
// Check for 'recipient' field (the 'sender' field and others are ignored here)
if ($discoveryInstance->isRecipientListEmpty()) {
// The recipient is this node so next stack it on 'decoded_package'
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-DECODER: Pushing ' . strlen($decodedData) . ' bytes to stack ' . self::STACKER_NAME_DECODED_PACKAGE . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-DECODER: Pushing ' . strlen($decodedData) . ' bytes to stack ' . self::STACKER_NAME_DECODED_PACKAGE . ' ...');
$this->getHandlerInstance()->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_PACKAGE, $decodedData);
} else {
// Forward the package to the next node
$decodedData = $this->getHandlerInstance()->getStackInstance()->popNamed(self::STACKER_NAME_DECODED_PACKAGE);
// Handle it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-DECODER: decodedData(' . count($decodedData) . ')=' . print_r($decodedData, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-DECODER: decodedData(' . count($decodedData) . ')=' . print_r($decodedData, TRUE));
$this->getPackageInstance()->handleRawData($decodedData);
}
$discoveryInstance = new PackageSocketDiscovery();
// Output debug message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: Initialized.');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: Initialized.');
// Return the prepared instance
return $discoveryInstance;
*/
public function discoverListenerInstance (HandleableProtocol $protocolInstance, array $packageData) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: protocolInstance=' . $protocolInstance->__toString() . ' - CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: protocolInstance=' . $protocolInstance->__toString() . ' - CALLED!');
/*
* Get the listener pool instance, we need to lookup the matching
$protocolName = $protocolInstance->getProtocolName();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: protocolName=' . $protocolName);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: protocolName=' . $protocolName);
// Debugging
//* DEBUG-DIE: */ die(__METHOD__.':poolInstance='.print_r($poolInstance, TRUE));
*/
foreach ($poolInstance->getArrayFromList($protocolName) as $listenerInstance) {
// Debug output
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: protocolName=' . $protocolName . ',listenerInstance[' . gettype($listenerInstance) . ']=' . $listenerInstance);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: protocolName=' . $protocolName . ',listenerInstance[' . gettype($listenerInstance) . ']=' . $listenerInstance);
// Make sure the instance is valid
assert($listenerInstance instanceof Listenable);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-DISCOVERY: Calling listenerInstance->ifListenerAcceptsPackageData(%d) ...', count($packageData)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('PACKAGE-SOCKET-DISCOVERY: Calling listenerInstance->ifListenerAcceptsPackageData(%d) ...', count($packageData)));
// Does the listener want that package?
if ($listenerInstance->ifListenerAcceptsPackageData($packageData)) {
// This listener likes our package data, so abort here
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-DISCOVERY: Listener "%s" is accepting package data.', $listenerInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('PACKAGE-SOCKET-DISCOVERY: Listener "%s" is accepting package data.', $listenerInstance->__toString()));
break;
} // END - if
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: Listener is NOT accepting package data.');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: Listener is NOT accepting package data.');
} // END - foreach
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: listenerInstance=' . $listenerInstance->__toString());
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: listenerInstance=' . $listenerInstance->__toString());
// Return it
return $listenerInstance;
$listenerInstance = $this->discoverListenerInstance($protocolInstance, $packageData);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('listenerInstance=' . $listenerInstance . ',packageData=' . print_r($packageData, TRUE));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: listenerInstance=' . $listenerInstance . ',packageData=' . print_r($packageData, TRUE));
// If there is no listener who wants to have that package, we simply drop it here
if (is_null($listenerInstance)) {
throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
} elseif (is_null($listenerInstance->getPoolInstance())) {
// Opps another one
- throw new LogicException(sprintf('listenerInstance=%s has no poolInstance set.', $listenerInstance->__toString()), self::EXCEPTION_IS_NULL_POINTER);
+ throw new LogicException(sprintf('PACKAGE-SOCKET-DISCOVERY: listenerInstance=%s has no poolInstance set.', $listenerInstance->__toString()), self::EXCEPTION_IS_NULL_POINTER);
}
/*
$socketInstance = $listenerInstance->getPoolInstance()->getSocketFromPackageData($packageData, $connectionType);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-DISCOVERY: socketInstance[]=%s', gettype($socketInstance)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('PACKAGE-SOCKET-DISCOVERY: socketInstance[]=%s', gettype($socketInstance)));
// Is it FALSE, the recipient isn't known to us and we have no connection to it
if (!($socketInstance instanceof StorableSocket) || ($socketInstance->isValidSocket()) || ($socketInstance->getLastSocketErrorCode() > 0)) {
// Try to create a new socket resource
try {
// Possibly noisy debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: Trying to establish a ' . strtoupper($listenerInstance->getProtocolName()) . ' connection to ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: Trying to establish a ' . strtoupper($listenerInstance->getProtocolName()) . ' connection to ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' ...');
// Get a socket resource from our factory (if succeeded)
$socketInstance = SocketFactory::createSocketFromPackageData($packageData, $protocolInstance);
} catch (SocketConnectionException $e) {
// The connection fails of being established, so log it away
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: Caught ' . $e->__toString() . ',message=' . $e->getMessage());
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: Caught ' . $e->__toString() . ',message=' . $e->getMessage());
}
} // END - if
$helperInstance = Registry::getRegistry()->getInstance('connection');
// Possibly noisy debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: Going to resolve socket from peer state and given package data ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: Going to resolve socket from peer state and given package data ...');
// Resolve the peer's state (but ignore return value)
PeerStateResolver::resolveStateByPackage($helperInstance, $packageData, $socketInstance);
} catch (InvalidSocketException $e) {
// This cannot be fixed, so log it away
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: Cannot discover socket resource for recipient ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ': ' . $e->getMessage());
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: Cannot discover socket resource for recipient ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ': ' . $e->getMessage());
// Make any failed attempts to 'FALSE'
$socketInstance = NULL;
}
// And return it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: socketResource=' . $socketInstance->getSocketResource() . ',packageData=' . print_r($packageData, TRUE));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: socketResource=' . $socketInstance->getSocketResource() . ',packageData=' . print_r($packageData, TRUE));
return $socketInstance;
}
*/
public static final function createUnlInstanceFromString ($unl) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNL-FACTORY: unl=%s - CALLED!', $unl));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNL-FACTORY: unl=%s - CALLED!', $unl));
// If there is no handler?
if (Registry::getRegistry()->instanceExists('unl_' . $unl)) {
$registryKey = 'socket_' . $protocolInstance->getProtocolName() . '_' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT];
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Trying to find a socket with registryKey=' . $registryKey);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Trying to find a socket with registryKey=' . $registryKey);
// Is the key there?
if (Registry::getRegistry()->instanceExists($registryKey)) {
$socketInstance = Registry::getRegistry()->getInstance($registryKey);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Using socket ' . $socketInstance->getSocketResource() . '(' . gettype($socketInstance->getSocketResource()) . ') from registry.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Using socket ' . $socketInstance->getSocketResource() . '(' . gettype($socketInstance->getSocketResource()) . ') from registry.');
} else {
// Construct configuration entry for object factory and get it
$className = FrameworkConfiguration::getSelfInstance()->getConfigEntry($protocolInstance->getProtocolName() . '_connection_helper_class');
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Going to use class ' . $className . ' for creating a socket resource ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Going to use class ' . $className . ' for creating a socket resource ...');
// And call the static method
$socketInstance = call_user_func($className . '::createConnectionFromPackageData', $packageData);
Registry::getRegistry()->addInstance($registryKey, $socketInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Socket is now registered in registry.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Socket is now registered in registry.');
}
// Trace message
- /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString()));
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString()));
// Return the socket (container) instance
return $socketInstance;
$socketInstance = self::createObjectByConfiguredName('socket_container_class', array($socketResource, StorableSocket::SOCKET_PROTOCOL_FILE, $packageData));
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance[]=%s', gettype($socketInstance)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance[]=%s', gettype($socketInstance)));
// Is the socket resource valid?
if (!$socketInstance->isValidSocket()) {
} // END - if
// Trace message
- /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString()));
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString()));
// Return socket instance
return $socketInstance;
$socketResource = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Created socket[' . gettype($socketResource) . ']=' . $socketResource . '.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Created socket[' . gettype($socketResource) . ']=' . $socketResource . '.');
// Construct container class, this won't be reached if an exception is thrown
$socketInstance = ObjectFactory::createObjectByConfiguredName('socket_container_class', array($socketResource, StorableSocket::SOCKET_PROTOCOL_TCP, $packageData));
} // END - if
// Trace message
- /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString()));
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString()));
// Return it
return $socketInstance;
*/
public static function createListenTcpSocket (Listenable $listenerInstance) {
// Trace message
- /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: listenerInstance=%s - CALLED!', $listenerInstance->__toString()));
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: listenerInstance=%s - CALLED!', $listenerInstance->__toString()));
// Create a streaming socket, of type TCP/IP
$socketResource = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
} // END - if
// Trace message
- /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString()));
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString()));
// Return prepepared socket
return $socketInstance;
*/
public static function createListenUdpSocket (Listenable $listenerInstance) {
// Trace message
- /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: listenerInstance=%s - CALLED!', $listenerInstance->__toString()));
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: listenerInstance=%s - CALLED!', $listenerInstance->__toString()));
// Create a streaming socket, of type TCP/IP
$socketResource = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
} // END - if
// Trace message
- /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString()));
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString()));
// Return prepepared socket
return $socketInstance;
*/
public static final function createNextAcceptedSocketFromPool (Poolable $poolInstance, StorableSocket $socketInstance) {
// Trace message
- /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: poolInstance=%s,socketInstance.socketResource=%s - CALLED!', $poolInstance->__toString(), $socketInstance->getSocketResource()));
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: poolInstance=%s,socketInstance.socketResource=%s - CALLED!', $poolInstance->__toString(), $socketInstance->getSocketResource()));
// Get socket protocol
$socketProtocol = $socketInstance->getSocketProtocol();
$acceptedSocketInstance = $current[Poolable::SOCKET_ARRAY_INSTANCE]->acceptNewIncomingSocket();
// Trace message
- /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: acceptedSocketInstance[]=%s - EXIT!', gettype($acceptedSocketInstance)));
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: acceptedSocketInstance[]=%s - EXIT!', gettype($acceptedSocketInstance)));
// Return found socket instance
return $acceptedSocketInstance;
// Try to identify socket peer
if (!$socketInstance->identifySocketPeer()) {
// Handle this socket error with a faked recipientData array
- $socketInstance->handleSocketEror(__METHOD__, __LINE__, array('0.0.0.0', '0'));
+ $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0'));
} // END - if
// Set timeout to configured seconds
if (!$socketInstance->setSocketTimeoutOptions()) {
// Handle this socket error with a faked recipientData array
- $socketInstance->handleSocketEror(__METHOD__, __LINE__, array('0.0.0.0', '0'));
+ $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0'));
} // END - if
// Enable SO_OOBINLINE
if (!$socketInstance->enableSocketOutOfBandData()) {
// Handle this socket error with a faked recipientData array
- $socketInstance->handleSocketEror(__METHOD__, __LINE__, array('0.0.0.0', '0'));
+ $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0'));
} // END - if
// Set non-blocking
} // END - if
// Trace message
- /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString()));
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString()));
// Return found socket instance
return $socketInstance;
// For any purposes, return the state instance
return $stateInstance;
}
-}
-// [EOF]
-?>
+}
// For any purposes, return the state instance
return $stateInstance;
}
-}
-// [EOF]
-?>
+}
// For any purposes, return the state instance
return $stateInstance;
}
-}
-// [EOF]
-?>
+}
// For any purposes, return the state instance
return $stateInstance;
}
-}
-// [EOF]
-?>
+}
// For any purposes, return the state instance
return $stateInstance;
}
-}
-// [EOF]
-?>
+}
$tableInstance->purgeOldEntriesBySocketInstance($socketInstance);
} catch (InvalidSocketException $e) {
// Just log all errors
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] Purging of old entries failed. Message from exception: ' . $e->getMessage());
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY: Purging of old entries failed. Message from exception: ' . $e->getMessage());
}
// Do we have an entry?
if ($tableInstance->isSenderNewPeer($packageData)) {
// Debug output
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] errorCode=' . $errorCode);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY: errorCode=' . $errorCode);
// Register the new peer with its session id
$tableInstance->registerPeerByPackageData($packageData, $socketInstance);
$tableInstance->registerPeerState($stateInstance, $packageData);
} elseif ($tableInstance->isSamePeerState($helperInstance, $packageData)) {
// Debug output
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] Peer state unchanged, re-generating old state ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY: Peer state unchanged, re-generating old state ...');
/*
* The peer's state has noot changed, still we have to return a
$stateInstance = self::createPeerStateInstanceByName($helperInstance->getPrintableState(), $helperInstance);
} else {
// Debug output
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] Updating peer state ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY: Updating peer state ...');
/*
* It is an already known peer but with a changed state. So first
}
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] Peer state has changed from ' . $helperInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . ' (' . $stateInstance->__toString() . ').');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY: Peer state has changed from ' . $helperInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . ' (' . $stateInstance->__toString() . ').');
// Set the state in the helper
$helperInstance->setStateInstance($stateInstance);
$stateInstance = self::createObjectByConfiguredName('peer_' . $stateName . '_state_class', array($helperInstance));
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] Peer state has changed from ' . $helperInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . ' (' . $stateInstance->__toString() . ').');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY: 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);
*/
private function initHandler () {
// Noisy debug line:
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: Initializing handler ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: Initializing handler ...');
// Init finalPackageChunks
$this->finalPackageChunks = array(
*/
private function isChunkHashValid (array $chunkSplits) {
// Noisy debug line:
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: chunkSplits=' . print_r($chunkSplits, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: chunkSplits=' . print_r($chunkSplits, TRUE));
// Assert on some elements
assert(isset($chunkSplits[self::CHUNK_SPLITS_INDEX_RAW_DATA]));
$isValid = ($chunkSplits[self::CHUNK_SPLITS_INDEX_HASH] === $chunkHash);
// Debug output
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: chunkHash=' . $chunkHash . ',isValid=' . intval($isValid));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: chunkHash=' . $chunkHash . ',isValid=' . intval($isValid));
// ... and return it
return $isValid;
} // END - if
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: serialNumber=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL] . ',hash=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: serialNumber=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL] . ',hash=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH]);
// Add the chunk data (index 2) to the final array and use the serial number as index
$this->finalPackageChunks['content'][$chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL]] = $chunkSplits[self::CHUNK_SPLITS_INDEX_RAW_DATA];
*/
private function verifyChunkSerialNumbers () {
// Debug message
- /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: finalPackageChunks=' . print_r($this->finalPackageChunks, TRUE));
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: finalPackageChunks=' . print_r($this->finalPackageChunks, TRUE));
// Get final hash
$finalHash = $this->generateFinalHash(implode('', $this->finalPackageChunks['content']));
$nextSerial = $this->fragmenterInstance->getNextHexSerialNumber($finalHash);
// Debug output
- /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: serialNumber=' . $serialNumber . ',nextSerial=' . $nextSerial);
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: serialNumber=' . $serialNumber . ',nextSerial=' . $nextSerial);
// Is it not the same? Then re-request it
if ($serialNumber != $nextSerial) {
$this->rawPackageData = '';
// That went well, so start assembling all chunks
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: Handling ' . count($this->finalPackageChunks['content']) . ' entries ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: Handling ' . count($this->finalPackageChunks['content']) . ' entries ...');
foreach ($this->finalPackageChunks['content'] as $serialNumber => $content) {
// Assert on 'hash' entry (must always be set)
assert(isset($this->finalPackageChunks['hashes'][$serialNumber]));
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: serialNumber=' . $serialNumber . ',hashes=' . $this->finalPackageChunks['hashes'][$serialNumber] . ' - validating ...');
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('finalPackageChunks=' . print_r($this->finalPackageChunks, TRUE) . 'chunkHashes=' . print_r($this->chunkHashes, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: serialNumber=' . $serialNumber . ',hashes=' . $this->finalPackageChunks['hashes'][$serialNumber] . ' - validating ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('finalPackageChunks=' . print_r($this->finalPackageChunks, TRUE) . 'chunkHashes=' . print_r($this->chunkHashes, TRUE));
// Is this chunk valid? This should be the case
assert($this->isChunkHashValid(array(
assert(in_array($this->finalPackageChunks['hashes'][$serialNumber], $this->chunkHashes));
// Verification okay, add it to the raw data
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: Adding ' . strlen($content) . ' bytes as raw package data ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: Adding ' . strlen($content) . ' bytes as raw package data ...');
$this->rawPackageData .= $content;
} // END - foreach
// Debug output
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: eopChunk[1]=' . $this->eopChunk[1] . ',index=' . (count($this->chunkHashes) - 2) . ',chunkHashes='.print_r($this->chunkHashes, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: eopChunk[1]=' . $this->eopChunk[1] . ',index=' . (count($this->chunkHashes) - 2) . ',chunkHashes='.print_r($this->chunkHashes, TRUE));
// The last chunk hash must match with the one from eopChunk[1]
assert($this->eopChunk[1] == $this->chunkHashes[count($this->chunkHashes) - 2]);
$finalHash = $this->generateFinalHash($this->rawPackageData);
// Is it the same?
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: eopChunk[1]=' . $this->eopChunk[1] . ',finalHash=' . $finalHash);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: eopChunk[1]=' . $this->eopChunk[1] . ',finalHash=' . $finalHash);
assert($finalHash == $this->eopChunk[0]);
}
$chunkSplits = explode(PackageFragmenter::CHUNK_DATA_HASH_SEPARATOR, $chunks[count($chunks) - 1]);
// Make sure chunks with only 3 elements are parsed (for details see ChunkHandler)
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('eopChunk=' . $chunks[count($chunks) - 1] . ',chunkSplits=' . print_r($chunkSplits, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('eopChunk=' . $chunks[count($chunks) - 1] . ',chunkSplits=' . print_r($chunkSplits, TRUE));
assert(count($chunkSplits) == 3);
// Validate final chunk
*/
public function ifRawPackageDataIsAvailable () {
// Check it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: this->rawPackageData()=' . strlen($this->rawPackageData) . ',ifUnassembledChunksAvailable()=' . intval($this->ifUnassembledChunksAvailable()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: this->rawPackageData()=' . strlen($this->rawPackageData) . ',ifUnassembledChunksAvailable()=' . intval($this->ifUnassembledChunksAvailable()));
$isRawPackageDataAvailable = ((!empty($this->rawPackageData)) && (!$this->ifUnassembledChunksAvailable()));
// Return it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: isRawPackageDataAvailable=' . intval($isRawPackageDataAvailable));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: isRawPackageDataAvailable=' . intval($isRawPackageDataAvailable));
return $isRawPackageDataAvailable;
}
assert($this->ifRawPackageDataIsAvailable());
// Then feed it into the next stacker
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: Pushing ' . strlen($this->rawPackageData) . ' bytes to stack ' . self::STACKER_NAME_ASSEMBLED_RAW_DATA . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: Pushing ' . strlen($this->rawPackageData) . ' bytes to stack ' . self::STACKER_NAME_ASSEMBLED_RAW_DATA . ' ...');
$this->getStackInstance()->pushNamed(self::STACKER_NAME_ASSEMBLED_RAW_DATA, $this->rawPackageData);
// ... and reset it
$this->rawPackageData = '';
}
-}
-// [EOF]
-?>
+}
*/
protected function prepareAnswerMessage (array $messageData, Deliverable $packageInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MESSAGE-HANDLER: Going to send an answer message for ' . $this->getHandlerName() . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATA-HANDLER:Going to send an answer message for ' . $this->getHandlerName() . ' ...');
// Get a helper instance based on this handler's name
$helperInstance = ObjectFactory::createObjectByConfiguredName('node_answer_' . $this->getHandlerName() . '_helper_class', array($messageData));
$this->removeMessageConfigurationData($messageData);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MESSAGE-HANDLER: Answer message has been prepared.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATA-HANDLER:Answer message has been prepared.');
}
/**
*/
protected function prepareNextMessage (array $messageData, Deliverable $packageInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MESSAGE-HANDLER: Going to send next message ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATA-HANDLER:Going to send next message ...');
// Get a helper instance based on this handler's name
$helperInstance = ObjectFactory::createObjectByConfiguredName('node_next_' . $this->getHandlerName() . '_helper_class', array($messageData));
$this->removeMessageConfigurationData($messageData);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MESSAGE-HANDLER: Next message has been prepared.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATA-HANDLER:Next message has been prepared.');
}
/**
*/
protected final function isValidUniversalNodeLocator ($unl) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PROTOCOL-HANDLER: unl=' . $unl . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PROTOCOL-HANDLER: unl=' . $unl . ' - CALLED!');
// Very basic regex check
$isValid = (preg_match($this->getRegularExpression(), $unl) === 1);
// Return result
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PROTOCOL-HANDLER: isValid=' . intval($isValid) . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PROTOCOL-HANDLER: isValid=' . intval($isValid) . ' - EXIT!');
return $isValid;
}
$internalUnl = HubTools::determineOwnInternalAddress();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PROTOCOL-HANDLER: unl=' . $unl . ',externalUnl=' . $externalUnl . ',internalUnl=' . $internalUnl);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PROTOCOL-HANDLER: unl=' . $unl . ',externalUnl=' . $externalUnl . ',internalUnl=' . $internalUnl);
//* DIE-DEBUG: */ die(__METHOD__.':unl=' . $unl . ',this='.print_r($this, TRUE));
// Is it the same?
$ifMatches = (($unl === $externalUnl) || ($unl === $internalUnl));
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PROTOCOL-HANDLER: ifMatches=' . intval($ifMatches));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PROTOCOL-HANDLER: ifMatches=' . intval($ifMatches));
// Return result
return $ifMatches;
*/
public function isValidUniversalNodeLocatorByPackageData (array $packageData) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('IPV4-PROTOCOL-HANDLER: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('IPV4-PROTOCOL-HANDLER: CALLED!');
// Is 'recipient' there?
assert(isset($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
$isValid = $this->isValidUniversalNodeLocator($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('IPV4-PROTOCOL-HANDLER: PACKAGE_DATA_RECIPIENT=' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ',isValid[' . gettype($isValid) . ']=' . intval($isValid));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('IPV4-PROTOCOL-HANDLER: PACKAGE_DATA_RECIPIENT=' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ',isValid[' . gettype($isValid) . ']=' . intval($isValid));
// If this doesn't fail, continue validating the IP:port combination
if ($isValid === TRUE) {
} // END - if
// Return result
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('IPV4-PROTOCOL-HANDLER: isValid=' . intval($isValid) . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('IPV4-PROTOCOL-HANDLER: isValid=' . intval($isValid) . ' - EXIT!');
return $isValid;
}
*/
protected function initStack () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-DATA-HANDLER: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-DATA-HANDLER: CALLED!');
// Init stack(s)
$this->getStackInstance()->initStack(self::STACKER_NAME_RAW_DATA);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-DATA-HANDLER: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-DATA-HANDLER: EXIT!');
}
/**
*/
protected function addRawDataToStacker ($rawData) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-HANDLER: rawData()=%d - CALLED!', strlen($rawData)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-HANDLER: rawData()=%d - CALLED!', strlen($rawData)));
/*
* Add the deocoded data and error code to the stacker so other classes
));
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-DATA-HANDLER: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-DATA-HANDLER: EXIT!');
}
/**
*/
public function isRawDataPending () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-DATA-HANDLER: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-DATA-HANDLER: CALLED!');
// Does the stacker have some entries (not empty)?
$isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_RAW_DATA));
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-HANDLER: isPending=%d - EXIT!', intval($isPending)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-HANDLER: isPending=%d - EXIT!', intval($isPending)));
// Return it
return $isPending;
*/
protected function ifRecipientMatchesOwnUniversalNodeLocator (array $packageData) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-HANDLER: packageData()=%d - CALLED!', strlen($packageData)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-HANDLER: packageData()=%d - CALLED!', strlen($packageData)));
// Construct own address first
$ownAddress = NodeObjectFactory::createNodeInstance()->determineUniversalNodeLocator();
$matches = ($ownAddress === $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-HANDLER: matches=%d - EXIT!', intval($matches)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-HANDLER: matches=%d - EXIT!', intval($matches)));
// Return result
return $matches;
*/
private function getRawDataFromPackageArray (array $packageData) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: currentFinalHash=' . $this->currentFinalHash);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: currentFinalHash=' . $this->currentFinalHash);
// Make sure the final hash is set
assert((is_string($this->currentFinalHash)) && (!empty($this->currentFinalHash)));
$rawDataChunk = $this->getFragmenterInstance()->getNextRawDataChunk($this->currentFinalHash);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: rawDataChunk=' . print_r($rawDataChunk, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: rawDataChunk=' . print_r($rawDataChunk, TRUE));
// Get chunk hashes and chunk data
$chunkHashes = array_keys($rawDataChunk);
$chunkData = array_values($rawDataChunk);
// Is the required data there?
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: chunkHashes[]=' . count($chunkHashes) . ',chunkData[]=' . count($chunkData));
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('chunkData='.print_r($chunkData, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: chunkHashes[]=' . count($chunkHashes) . ',chunkData[]=' . count($chunkData));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('chunkData='.print_r($chunkData, TRUE));
if ((isset($chunkHashes[0])) && (isset($chunkData[0]))) {
// Remember this chunk as queued
$this->queuedChunks[$chunkHashes[0]] = $chunkData[0];
// Return the raw data
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Returning ' . strlen($chunkData[0]) . ' bytes from ' . __METHOD__ . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Returning ' . strlen($chunkData[0]) . ' bytes from ' . __METHOD__ . ' ...');
return $chunkData[0];
} else {
// Return zero string
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Returning zero bytes from ' . __METHOD__ . '!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Returning zero bytes from ' . __METHOD__ . '!');
return '';
}
}
*/
public function accept (Visitor $visitorInstance) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: visitorInstance=%s - CALLED!', $visitorInstance->__toString()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: visitorInstance=%s - CALLED!', $visitorInstance->__toString()));
// Just call the visitor
$visitorInstance->visitConnectionHelper($this);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: EXIT!');
}
/**
*/
public function sendRawPackageData (array $packageData) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: packageData()=%d - CALLED!', count($packageData)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: packageData()=%d - CALLED!', count($packageData)));
// The helper's state must be 'connected'
$this->getStateInstance()->validatePeerStateConnected();
$finalHash = $this->getFragmenterInstance()->fragmentPackageArray($packageData, $this);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: finalHash[%s]=%s', gettype($finalHash), $finalHash));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: finalHash[%s]=%s', gettype($finalHash), $finalHash));
// Is the final hash set?
if ($finalHash !== TRUE) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Setting finalHash=' . $finalHash . ',currentFinalHash[' . gettype($this->currentFinalHash) . ']=' . $this->currentFinalHash);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Setting finalHash=' . $finalHash . ',currentFinalHash[' . gettype($this->currentFinalHash) . ']=' . $this->currentFinalHash);
// Set final hash
$this->currentFinalHash = $finalHash;
// Fill sending buffer with data
while (TRUE) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: dataStream()=%d', strlen($dataStream)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: dataStream()=%d', strlen($dataStream)));
// Convert the package data array to a raw data stream
$dataStream = $this->getRawDataFromPackageArray($packageData);
} // END - if
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Adding ' . strlen($dataStream) . ' bytes to the sending buffer ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Adding ' . strlen($dataStream) . ' bytes to the sending buffer ...');
// Add raw data
$rawData .= $dataStream;
} // END - while
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: rawData()=%d', strlen($rawData)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: rawData()=%d', strlen($rawData)));
// Nothing to sent is bad news, so assert on it
assert(strlen($rawData) > 0);
$bufferSize = $this->getConfigInstance()->getConfigEntry($this->getProtocolName() . '_buffer_length');
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: bufferSize=%d', $bufferSize));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: bufferSize=%d', $bufferSize));
// Encode the raw data with our output-stream
$encodedData = $this->getOutputStreamInstance()->streamData($rawData);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: socketResource[]=' . gettype($this->getSocketInstance()->getSocketResource()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: socketResource[]=' . gettype($this->getSocketInstance()->getSocketResource()));
// Init array
$encodedDataArray = array(
$diff = $encodedDataArray[NetworkPackage::RAW_INDEX_BUFFER_SIZE] - strlen($encodedDataArray[NetworkPackage::RAW_INDEX_ENCODED_DATA]);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: diff=' . $diff);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: diff=' . $diff);
// Push raw data to the package's outgoing stack
$this->getPackageInstance()->getStackInstance()->pushNamed(NetworkPackage::STACKER_NAME_OUTGOING_STREAM, $encodedDataArray);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: EXIT!');
}
/**
* @return $shuttedDown Whether this connection is shutted down
*/
public final function isShuttedDown () {
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: ' . $this->__toString() . ',shuttedDown=' . intval($this->shuttedDown));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: ' . $this->__toString() . ',shuttedDown=' . intval($this->shuttedDown));
return $this->shuttedDown;
}
*/
public function loadDescriptorXml (Distributable $dhtInstance) {
// Debug message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HELPER: Starting with DHT boostrap ...');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HELPER: Starting with DHT boostrap ...');
// Get a XML template instance
$templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('dht_bootstrap_template_class');
*/
public function sendPackage (Distributable $dhtInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HELPER: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HELPER: CALLED!');
/*
* Sanity check: Is the DHT in the approx. state? 'init' for bootstrap
$packageInstance->enqueueRawDataFromTemplate($this);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HELPER: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HELPER: EXIT!');
}
}
namespace Hub\Information\Connection;
// Import application-specific stuff
+use Hub\Container\Socket\StorableSocket;
use Hub\Helper\Connection\ConnectionHelper;
use Hub\Information\BaseInfo;
use Hub\Information\ShareableInfo;
// Import framework stuff
use CoreFramework\Registry\Registerable;
+use CoreFramework\Socket\InvalidSocketException;
/**
* A Connection information class
*/
public function fillWithListenerInformation (Listenable $listenerInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-INFO: protocolName=' . $listenerInstance->getProtocolName() . ',listenerInstance=' . $listenerInstance->__toString() . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-INFO: protocolName=' . $listenerInstance->getProtocolName() . ',listenerInstance=' . $listenerInstance->__toString() . ' - CALLED!');
// Fill the generic array with several data from the listener:
$this->setProtocolName($listenerInstance->getProtocolName());
$this->setListenerInstance($listenerInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-INFO: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-INFO: EXIT!');
}
/**
* @return void
*/
public function fillWithConnectionHelperInformation (ConnectionHelper $helperInstance) {
- // Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-INFO: protocolName=' . $helperInstance->getProtocolName() . ',helperInstance=' . $helperInstance->__toString() . ',socketResource=' . $helperInstance->getSocketResource() . ' - CALLED!');
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-INFO: protocolName=' . $helperInstance->getProtocolName() . ',helperInstance=' . $helperInstance->__toString() . ',socketResource=' . $helperInstance->getSocketResource() . ' - CALLED!');
// Fill the generic array with several data from the listener:
$this->setProtocolName($helperInstance->getSocketInstance()->getSocketProtocol());
// Set helper here
$this->setHelperInstance($helperInstance);
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-INFO: EXIT!');
+ }
+
+ /**
+ * Fills the information class with peer data from given socket instance
+ *
+ * @param $socketInstance An instance of a StorableSocket class
+ * @return void
+ * @throws InvalidSocketException If no peer data can be retrived from socket
+ */
+ public function fillWithSocketPeerInformation (StorableSocket $socketInstance) {
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-INFO: socketInstance.socketResource=%s - CALLED!', $socketInstance->getSocketResource()));
+
+ // Init variables
+ $socketAddress = '0.0.0.0';
+ $socketPort = '0';
+
+ // Get peer name
+ if (!$socketInstance->getSocketPeerName($socketAddress, $socketPort)) {
+ // Did not work
+ throw new InvalidSocketException(array($this, $socketInstance->getSocketResource()), self::EXCEPTION_INVALID_SOCKET);
+ } // END - if
+
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-INFO: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-INFO: socketAddress=%s,socketPort=%d', $socketAddress, $socketPort));
+
+ // Fill the generic array with several data from the listener:
+ $this->setProtocolName($socketInstance->getSocketProtocol());
+ $this->setGenericArrayElement('connection', 'dummy', 'dummy', LocateableNode::UNL_PART_ADDRESS , $socketAddress);
+ $this->setGenericArrayElement('connection', 'dummy', 'dummy', LocateableNode::UNL_PART_PORT , $socketPort);
+
+ // Set socket here
+ $this->setSocketInstance($socketInstance);
+
+ // Debugging:
+ //* DEBUG-DIE: */ die(sprintf('[%s:%d]: socketInstance=%s', __METHOD__, __LINE__, print_r($socketInstance, TRUE)));
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-INFO: EXIT!');
}
/**
*/
protected function registerServerSocketInstance (StorableSocket $socketInstance) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: socketInstance=%s - CALLED!', $socketInstance->__toString()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: socketInstance=%s - CALLED!', $socketInstance->__toString()));
// First check if it is valid
if ($this->isServerSocketRegistered($socketInstance)) {
$registryInstance->registerSocketInstance($infoInstance, $socketInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: Setting socketInstance ... (socketResource=%s)', $socketInstance->getSocketResource()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: Setting socketInstance ... (socketResource=%s)', $socketInstance->getSocketResource()));
// And set it here
$this->setSocketInstance($socketInstance);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER: EXIT!');
}
/**
*/
protected function isServerSocketRegistered (StorableSocket $socketInstance) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: socketInstance=%s - CALLED!', $socketInstance->__toString()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: socketInstance=%s - CALLED!', $socketInstance->__toString()));
// Get a socket registry instance (singleton)
$registryInstance = SocketRegistryFactory::createSocketRegistryInstance();
$infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($this->getProtocolName(), 'listener');
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: infoInstance[]=%s', gettype($infoInstance)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: infoInstance[]=%s', gettype($infoInstance)));
// Is the instance set?
if (!($infoInstance instanceof ShareableInfo)) {
$infoInstance->fillWithListenerInformation($this);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: Checking socketInstance ... (socketResource=%s)', $socketInstance->getSocketResource()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: Checking socketInstance ... (socketResource=%s)', $socketInstance->getSocketResource()));
// Check it
$isRegistered = $registryInstance->isSocketRegistered($infoInstance, $socketInstance);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: isRegistered=%d - EXIT!', intval($isRegistered)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: isRegistered=%d - EXIT!', intval($isRegistered)));
// Return result
return $isRegistered;
*/
public function accept (Visitor $visitorInstance) {
// Debug message
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getProtocolName()) . '-LISTENER: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getProtocolName()) . '-LISTENER: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - CALLED!');
// Visit this listener
$visitorInstance->visitListener($this);
} // END - if
// Debug message
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getProtocolName()) . '-LISTENER: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getProtocolName()) . '-LISTENER: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - EXIT!');
}
/**
*/
protected function doListenSocketSelect ($peerSuffix) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: peerSuffix=%s - CALLED!', $peerSuffix));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: peerSuffix=%s - CALLED!', $peerSuffix));
// Check on all instances
assert($this->getPoolInstance() instanceof Poolable);
$socketInstance = SocketFactory::createNextAcceptedSocketFromPool($this->getPoolInstance(), $this->getSocketInstance());
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: socketInstance[]=%s accepted.', gettype($socketInstance)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: socketInstance[]=%s accepted.', gettype($socketInstance)));
// Is socket instance set?
if (!($socketInstance instanceof StorableSocket)) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER: No new connection on listener ... - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER: No new connection on listener ... - EXIT!');
// Nothing has changed on the listener
return;
} // END - if
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: socketInstance.socketResource=%s accepted.', $socketInstance->getSocketResource()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: socketInstance.socketResource=%s accepted.', $socketInstance->getSocketResource()));
// Init peer address/port
$peerAddress = '0.0.0.0';
$currentSocketData = $this->getIteratorInstance()->current();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER: currentSocketData=' . $currentSocketData[Poolable::SOCKET_ARRAY_INSTANCE] . ',type=' . $currentSocketData[Poolable::SOCKET_ARRAY_CONN_TYPE] . ',serverSocket=' . $this->getSocketInstance()->getSocketResource());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER: currentSocketData=' . $currentSocketData[Poolable::SOCKET_ARRAY_INSTANCE] . ',type=' . $currentSocketData[Poolable::SOCKET_ARRAY_CONN_TYPE] . ',serverSocket=' . $this->getSocketInstance()->getSocketResource());
// Handle it here, if not main server socket
if (($currentSocketData[Poolable::SOCKET_ARRAY_CONN_TYPE] != StorableSocket::CONNECTION_TYPE_SERVER) && (!$currentSocketData[Poolable::SOCKET_ARRAY_INSTANCE]->equals($this->getSocketInstance()))) {
$this->getIteratorInstance()->next();
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER: EXIT!');
}
/**
*/
public function ifListenerAcceptsPackageData (array $packageData) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: packageData()=%d - CALLED!', count($packageData)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: packageData()=%d - CALLED!', count($packageData)));
// Check if same socket protocol
$socketProtocol = $this->getSocketInstance()->getSocketProtocol();
$unlProtocol = $unlInstance->getUnlProtocol();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: unlInstance.unlProtocol=%s,socketProtocol=%s', $unlProtocol, $socketProtocol));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: unlInstance.unlProtocol=%s,socketProtocol=%s', $unlProtocol, $socketProtocol));
// Is same protocol?
$accepts = ($unlProtocol == $socketProtocol);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: accepts=%d - EXIT!', $accepts));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: accepts=%d - EXIT!', $accepts));
// Return the result
return $accepts;
*/
public final function getListenAddress () {
// Trace message
- /* NOSY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: Calling this->getListenerInstance()->getListenAddress() ...');
+ //* NOSY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: Calling this->getListenerInstance()->getListenAddress() ...');
return $this->getListenerInstance()->getListenAddress();
}
*/
public final function getListenPort () {
// Trace message
- /* NOSY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: Calling this->getListenerInstance()->getListenPort() ...');
+ //* NOSY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: Calling this->getListenerInstance()->getListenPort() ...');
return $this->getListenerInstance()->getListenPort();
}
*/
public final function getPoolInstance () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER-DECORATOR: Getting poolInstance from inner listenerInstance=%s - CALLED!', $this->getListenerInstance()->__toString()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER-DECORATOR: Getting poolInstance from inner listenerInstance=%s - CALLED!', $this->getListenerInstance()->__toString()));
// Get it
return $this->getListenerInstance()->getPoolInstance();
*/
public function monitorIncomingRawData () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: CALLED!');
// Get the handler instance
$handlerInstance = $this->getListenerInstance()->getHandlerInstance();
*/
if (!$handlerInstance instanceof Networkable) {
// Skip this silently for now. Later on, this will become mandatory!
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: No handler assigned to this listener decorator. this=' . $this->__toString() . ', listenerInstance=' . $this->getListenerInstance()->__toString());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: No handler assigned to this listener decorator. this=' . $this->__toString() . ', listenerInstance=' . $this->getListenerInstance()->__toString());
return;
} // END - if
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER-DECORATOR: handlerInstance=%s', $handlerInstance->__toString()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER-DECORATOR: handlerInstance=%s', $handlerInstance->__toString()));
// Does the handler have some decoded data pending?
if (!$handlerInstance->isRawDataPending()) {
// No data is pending so skip further code silently
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: No data pending on handlerInstance=' . $handlerInstance->__toString() . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: No data pending on handlerInstance=' . $handlerInstance->__toString() . ' - EXIT!');
return;
} // END - if
* know if the decoded data origins from a TCP or UDP connection so it
* can just be passed over to the network package receiver.
*/
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: Going to handle over some raw data to receiverInstance=' . $receiverInstance->__toString() . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: Going to handle over some raw data to receiverInstance=' . $receiverInstance->__toString() . ' ...');
$receiverInstance->addRawDataToIncomingStack($handlerInstance);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: EXIT!');
}
/**
*/
public function doListen() {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: Calling this->doListenSocketSelect() ... - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: Calling this->doListenSocketSelect() ... - CALLED!');
// Call super method
$this->doListenSocketSelect('');
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: EXIT!');
}
/**
*/
public function ifListenerAcceptsPackageData (array $packageData) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FILE-LISTENER: packageData()=%d - CALLED!', count($packageData)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FILE-LISTENER: packageData()=%d - CALLED!', count($packageData)));
// Call parent method
if (!parent::ifListenerAcceptsPackageData($packageData)) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: Protocol mismatching, not accepting package.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: Protocol mismatching, not accepting package.');
// Is already different protocol
return FALSE;
$accepts = $tagsInstance->ifPackageDataIsAcceptedByListener($packageData, $this);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FILE-LISTENER: accepts=%d - EXIT!', $accepts));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FILE-LISTENER: accepts=%d - EXIT!', $accepts));
// Return the result
return $accepts;
*/
public function doListen () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-LISTENER: Calling this->doListenSocketSelect(:0) ... - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-LISTENER: Calling this->doListenSocketSelect(:0) ... - CALLED!');
// Call super method
$this->doListenSocketSelect(':0');
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-LISTENER: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-LISTENER: EXIT!');
}
/**
*/
public function doListen () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UDP-LISTENER: Calling this->doListenSocketSelect(:0) ... - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UDP-LISTENER: Calling this->doListenSocketSelect(:0) ... - CALLED!');
// Call super method
$this->doListenSocketSelect(':0');
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UDP-LISTENER: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UDP-LISTENER: EXIT!');
}
/**
*/
public function parseStringAsUnl ($unl) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNIVERSAL-NODE-LOCATOR: unl=[%s]=%s - CALLED!', gettype($unl), $unl));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNIVERSAL-NODE-LOCATOR: unl=[%s]=%s - CALLED!', gettype($unl), $unl));
// Is it basically valid?
if (!is_string($unl)) {
*/
private function parseUniversalNodeLocator ($unl) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNIVERSAL-NODE-LOCATOR: unl=[%s]=%s - CALLED!', gettype($unl), $unl));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNIVERSAL-NODE-LOCATOR: unl=[%s]=%s - CALLED!', gettype($unl), $unl));
// Make sure the UNL is valid
if (!$this->isValidUniversalNodeLocator($unl)) {
);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UNIVERSAL-NODE-LOCATOR: unlData=' . print_r($unlData, TRUE) . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UNIVERSAL-NODE-LOCATOR: unlData=' . print_r($unlData, TRUE) . ' - EXIT!');
// Call init method
$this->initUniversalNodeLocator($unlData);
*/
private final function isValidUniversalNodeLocator ($unl) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UNIVERSAL-NODE-LOCATOR: unl=' . $unl . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UNIVERSAL-NODE-LOCATOR: unl=' . $unl . ' - CALLED!');
// Very basic regex check
$isValid = (preg_match($this->getRegularExpression(), $unl) === 1);
// Return result
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UNIVERSAL-NODE-LOCATOR: isValid=' . intval($isValid) . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UNIVERSAL-NODE-LOCATOR: isValid=' . intval($isValid) . ' - EXIT!');
return $isValid;
}
*/
public function ifNodeIsAnnouncing () {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: ifNodeIsAnnouncing(): state=' . $this->getStateInstance()->getStateName());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: ifNodeIsAnnouncing(): state=' . $this->getStateInstance()->getStateName());
// Simply check the state of this node
$hasAnnounced = ($this->getStateInstance() instanceof NodeAnnouncingState);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: ifNodeIsAnnouncing(): hasAnnounced=' . intval($hasAnnounced));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: ifNodeIsAnnouncing(): hasAnnounced=' . intval($hasAnnounced));
// Return it
return $hasAnnounced;
*/
public function ifNodeHasAnnouncementCompleted () {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: ifNodeHasAnnouncementCompleted(): state=' . $this->getStateInstance()->getStateName());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: ifNodeHasAnnouncementCompleted(): state=' . $this->getStateInstance()->getStateName());
// Simply check the state of this node
$hasAnnouncementCompleted = ($this->getStateInstance() instanceof NodeAnnouncementCompletedState);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: ifNodeHasAnnouncementCompleted(): hasAnnouncementCompleted=' . intval($hasAnnouncementCompleted));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: ifNodeHasAnnouncementCompleted(): hasAnnouncementCompleted=' . intval($hasAnnouncementCompleted));
// Return it
return $hasAnnouncementCompleted;
* @return void
*/
public final function enableAcceptDhtBootstrap ($acceptDhtBootstrap = TRUE) {
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: Enabling DHT bootstrap requests ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: Enabling DHT bootstrap requests ...');
$this->acceptDhtBootstrap = $acceptDhtBootstrap;
}
*/
public function determineUniversalNodeLocator () {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: CALLED!');
// Is there cache?
if (!isset($GLOBALS[__METHOD__])) {
} // END - if
// Return it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: unlInstance= ' . $GLOBALS[__METHOD__]->__toString() . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: unlInstance= ' . $GLOBALS[__METHOD__]->__toString() . ' - EXIT!');
return $GLOBALS[__METHOD__];
}
$isInputBufferEmpty = $this->getPackageInstance()->getStackInstance()->isStackEmpty(NetworkPackage::STACKER_NAME_DECODED_HANDLED);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: isInputBufferEmpty=' . intval($isInputBufferEmpty));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: isInputBufferEmpty=' . intval($isInputBufferEmpty));
// Return it
return $isInputBufferEmpty;
*/
private function handlePackageByUnhandledPackage (array $packageContent) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: packageData[' . BaseRawDataHandler::PACKAGE_RAW_DATA . ']=' . $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: packageData[' . BaseRawDataHandler::PACKAGE_RAW_DATA . ']=' . $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]);
// Check for some conditions
if ((!$this->ifInputBufferIsEmpty()) || (!$this->isPackageContentCompleted($packageContent))) {
$this->pendingData .= $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA];
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: Partial data received. Waiting for more ... ( ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes)');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: Partial data received. Waiting for more ... ( ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes)');
} else {
// Debug message
//* DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: packageContent=' . print_r($packageContent, TRUE) . ',chunks='.print_r($chunks, TRUE));
$isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_MULTIPLE_MESSAGE));
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: isPending=' . intval($isPending) . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: isPending=' . intval($isPending) . ' - EXIT!');
// Return it
return $isPending;
*/
public function handlePendingData () {
// Debug output
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: Going to decode ' . strlen($this->pendingData) . ' Bytes of pending data. pendingData=' . $this->pendingData);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: Going to decode ' . strlen($this->pendingData) . ' Bytes of pending data. pendingData=' . $this->pendingData);
// Assert on condition
assert(!$this->isPendingDataEmpty());
// No markers set?
if (!$this->ifStartEndMarkersSet($this->pendingData)) {
// This will cause an assertition in next call, so simply wait for more data
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: Pending data of ' . strlen($this->pendingData) . ' Bytes are incomplete, waiting for more ...');
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: this->pendingData=' . $this->pendingData);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: Pending data of ' . strlen($this->pendingData) . ' Bytes are incomplete, waiting for more ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: this->pendingData=' . $this->pendingData);
return;
} elseif (substr_count($this->pendingData, BaseRawDataHandler::STREAM_START_MARKER) > 1) {
/*
$this->clearPendingData();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: Last block of partial data received. A total of ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes has been received.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: Last block of partial data received. A total of ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes has been received.');
// Make sure last CHUNK_SEPARATOR is not there
if (substr($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA], -1, 1) == PackageFragmenter::CHUNK_SEPARATOR) {
$chunks = explode(PackageFragmenter::CHUNK_SEPARATOR, $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]);
// Add all chunks because the last final chunk is found
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: Going to add ' . count($chunks) . ' to chunk handler ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: Going to add ' . count($chunks) . ' to chunk handler ...');
$this->getHandlerInstance()->addAllChunksWithFinal($chunks);
}
// Is an entry found?
if (count($senderData) > 0) {
// Make sure the element 'private_key_hash' is there
- /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: senderData=' . print_r($senderData, TRUE));
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: senderData=' . print_r($senderData, TRUE));
assert(isset($senderData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH]));
// Don't accept empty hashes
*/
private function getHashFromContent ($content) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content[md5]=' . md5($content) . ',sender=' . $this->getSessionId() . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content[md5]=' . md5($content) . ',sender=' . $this->getSessionId() . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension());
// Create the hash
// @TODO md5() is very weak, but it needs to be fast
);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content[md5]=' . md5($content) . ',sender=' . $this->getSessionId() . ',hash=' . $hash . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content[md5]=' . md5($content) . ',sender=' . $this->getSessionId() . ',hash=' . $hash . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension());
// And return it
return $hash;
*/
public function getHashFromContentSessionId (array $decodedContent, $sessionId) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content[md5]=' . md5($decodedContent[self::PACKAGE_CONTENT_MESSAGE]) . ',sender=' . $sessionId . ',compressor=' . $decodedContent[self::PACKAGE_CONTENT_EXTENSION]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content[md5]=' . md5($decodedContent[self::PACKAGE_CONTENT_MESSAGE]) . ',sender=' . $sessionId . ',compressor=' . $decodedContent[self::PACKAGE_CONTENT_EXTENSION]);
// Create the hash
// @TODO md5() is very weak, but it needs to be fast
$currentRecipient = $iteratorInstance->current();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Setting recipient to ' . $currentRecipient . ',previous=' . $packageData[self::PACKAGE_DATA_RECIPIENT]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Setting recipient to ' . $currentRecipient . ',previous=' . $packageData[self::PACKAGE_DATA_RECIPIENT]);
// Set the recipient
$packageData[self::PACKAGE_DATA_RECIPIENT] = $currentRecipient;
$this->getStackInstance()->pushNamed(self::STACKER_NAME_DECLARED, $packageData);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Package declared for recipient ' . $currentRecipient);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Package declared for recipient ' . $currentRecipient);
// Skip to next entry
$iteratorInstance->next();
*/
private function deliverRawPackageData (array $packageData) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: packageData()=%d - CALLED!', count($packageData)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: packageData()=%d - CALLED!', count($packageData)));
/*
* This package may become big, depending on the shared object size or
$socketInstance = $discoveryInstance->discoverSocket($packageData, StorableSocket::CONNECTION_TYPE_OUTGOING);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after discoverSocket() has been called.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after discoverSocket() has been called.');
// The socket needs to be put in a special registry that can handle such data
$registryInstance = SocketRegistryFactory::createSocketRegistryInstance();
$helperInstance = Registry::getRegistry()->getInstance('connection');
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: stateInstance=' . $helperInstance->getStateInstance());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: stateInstance=' . $helperInstance->getStateInstance());
// And make sure it is valid
assert($helperInstance instanceof ConnectionHelper);
$infoInstance->fillWithConnectionHelperInformation($helperInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' before isSocketRegistered() has been called.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' before isSocketRegistered() has been called.');
// Is it not there?
if (($socketInstance->isValidSocket()) && (!$registryInstance->isSocketRegistered($infoInstance, $socketInstance))) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Registering socket ' . $socketInstance . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Registering socket ' . $socketInstance . ' ...');
// Then register it
$registryInstance->registerSocketInstance($infoInstance, $socketInstance, $packageData);
}
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after isSocketRegistered() has been called.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after isSocketRegistered() has been called.');
// Make sure the connection is up
$helperInstance->getStateInstance()->validatePeerStateConnected();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after validatePeerStateConnected() has been called.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after validatePeerStateConnected() has been called.');
// Enqueue it again on the out-going queue, the connection is up and working at this point
$this->getStackInstance()->pushNamed(self::STACKER_NAME_OUTGOING, $packageData);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after pushNamed() has been called.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after pushNamed() has been called.');
}
/**
*/
private function generatePackageHash ($content, $senderId) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content()=' . strlen($content) . ',senderId=' . $senderId . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content()=' . strlen($content) . ',senderId=' . $senderId . ' - CALLED!');
// Is the feature enabled?
if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) {
// Feature is not enabled
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Feature "hubcoin_reward" not available, not generating package hash. Returning NULL ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Feature "hubcoin_reward" not available, not generating package hash. Returning NULL ...');
return NULL;
} // END - if
);
// Hash content and sender id together, use scrypt
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: senderId=' . $senderId . ',content()=' . strlen($content));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: senderId=' . $senderId . ',content()=' . strlen($content));
$hash = FrameworkFeature::callFeature('hubcoin_reward', 'generateHash', array($senderId . ':' . $content . ':' . $this->determineSenderPrivateKeyHash($data)));
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: hash=' . $hash . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: hash=' . $hash . ' - EXIT!');
// Return it
return $hash;
*/
private function isPackageHashValid (array $decodedArray) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: decodedArray=' . print_r($decodedArray, TRUE) . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: decodedArray=' . print_r($decodedArray, TRUE) . ' - CALLED!');
// Make sure the required array elements are there
assert(isset($decodedArray[self::PACKAGE_CONTENT_SENDER]));
// Is the feature enabled?
if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) {
// Feature is not enabled, so hashes are always valid
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Feature "hubcoin_reward" not available, not checking hash. Returning TRUE ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Feature "hubcoin_reward" not available, not checking hash. Returning TRUE ...');
return TRUE;
} // END - if
// Check validity
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: senderId=' . $decodedArray[self::PACKAGE_CONTENT_SENDER] . ',message()=' . strlen($decodedArray[self::PACKAGE_CONTENT_MESSAGE]) . ',hash=' . $decodedArray[self::PACKAGE_CONTENT_HASH]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: senderId=' . $decodedArray[self::PACKAGE_CONTENT_SENDER] . ',message()=' . strlen($decodedArray[self::PACKAGE_CONTENT_MESSAGE]) . ',hash=' . $decodedArray[self::PACKAGE_CONTENT_HASH]);
//* DEBUG-DIE: */ die(__METHOD__ . ': decodedArray=' . print_r($decodedArray, TRUE));
$isHashValid = FrameworkFeature::callFeature('hubcoin_reward', 'checkHash', array($decodedArray[self::PACKAGE_CONTENT_SENDER] . ':' . $decodedArray[self::PACKAGE_CONTENT_MESSAGE] . ':' . $this->determineSenderPrivateKeyHash($decodedArray), $decodedArray[self::PACKAGE_CONTENT_HASH]));
// Return it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: isHashValid=' . intval($isHashValid) . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: isHashValid=' . intval($isHashValid) . ' - EXIT!');
return $isHashValid;
}
*/
public function enqueueRawDataFromTemplate (HubHelper $helperInstance) {
// Debug message
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
// Get the raw content ...
$content = $helperInstance->getTemplateInstance()->getRawTemplateData();
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('content(' . strlen($content) . ')=' . $content);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('content(' . strlen($content) . ')=' . $content);
// ... and compress it
$compressed = $this->getCompressorInstance()->compressStream($content);
);
// Debug message
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Enqueueing package for recipientType=' . $helperInstance->getRecipientType() . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Enqueueing package for recipientType=' . $helperInstance->getRecipientType() . ' ...');
// Now prepare the temporary array and push it on the 'undeclared' stack
$this->getStackInstance()->pushNamed(self::STACKER_NAME_UNDECLARED, array(
));
// Debug message
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
}
/**
$isEnqueued = (($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_UNDECLARED)) && (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_UNDECLARED)));
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isEnqueued=%d - EXIT!', intval($isEnqueued)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isEnqueued=%d - EXIT!', intval($isEnqueued)));
// Return the result
return $isEnqueued;
$isDeclared = (($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_DECLARED)) && (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_DECLARED)));
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isDeclared=%d - EXIT!', intval($isDeclared)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isDeclared=%d - EXIT!', intval($isDeclared)));
// Return the result
return $isDeclared;
$isWaitingDelivery = (($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_OUTGOING)) && (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_OUTGOING)));
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isWaitingDelivery=%d - EXIT!', intval($isWaitingDelivery)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isWaitingDelivery=%d - EXIT!', intval($isWaitingDelivery)));
// Return the result
return $isWaitingDelivery;
$isPending = (($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_OUTGOING_STREAM)) && (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_OUTGOING_STREAM)));
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isPending=%d - EXIT!', intval($isPending)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isPending=%d - EXIT!', intval($isPending)));
// Return the result
return $isPending;
*/
public function declareEnqueuedPackage () {
// Debug message
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
// Make sure this method isn't working if there is no package enqueued
if (!$this->isPackageEnqueued()) {
$this->declareRawPackageData($packageData);
// Debug message
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
}
/**
*/
public function processDeclaredPackage () {
// Debug message
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
// Sanity check if we have packages declared
if (!$this->isPackageDeclared()) {
}
// Debug message
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
}
/**
*/
public function sendWaitingPackage () {
// Debug message
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
// Sanity check if we have packages waiting for delivery
if (!$this->isPackageWaitingForDelivery()) {
}
// Debug message
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
}
/**
*/
public function sendEncodedData () {
// Debug message
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
// Make sure there is pending encoded data
assert($this->isEncodedDataPending());
assert($encodedDataArray[self::RAW_INDEX_SOCKET_INSTANCE]->isValidSocket());
// Trace message
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: Calling socketInstance->writeBufferToSocketByArray(%d,%d) ...', count($encodedDataArray), $sentBytes));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: Calling socketInstance->writeBufferToSocketByArray(%d,%d) ...', count($encodedDataArray), $sentBytes));
// And deliver it
if (!$encodedDataArray[self::RAW_INDEX_SOCKET_INSTANCE]->writeBufferToSocketByArray($encodedDataArray, $sentBytes)) {
} // END - if
// Debug message
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: sentBytes[%s]=%d', gettype($sentBytes), $sentBytes));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: sentBytes[%s]=%d', gettype($sentBytes), $sentBytes));
// If there was an error, don't continue here
if (($sentBytes === 0) && (strlen($encodedDataArray[self::RAW_INDEX_ENCODED_DATA]) > 0)) {
// Nothing sent means all data has been sent
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: All sent! (LINE=' . __LINE__ . ')');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: All sent! (LINE=' . __LINE__ . ')');
return;
} elseif (strlen($encodedDataArray[self::RAW_INDEX_ENCODED_DATA]) <= 0) {
// Abort here, all sent!
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: All sent! (LINE=' . __LINE__ . ')');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: All sent! (LINE=' . __LINE__ . ')');
return;
}
$this->getStackInstance()->pushNamed(self::STACKER_NAME_OUTGOING_STREAM, $encodedDataArray);
// Debug message
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
}
///////////////////////////////////////////////////////////////////////////
*/
private function isRawDataPending () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
// Just return whether the stack is not empty
$isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_DECODED_INCOMING));
*/
public function isNewRawDataPending () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: Calling this->getListenerPoolInstance()->accept(%s) ... - CALLED!', $this->getVisitorInstance()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: Calling this->getListenerPoolInstance()->accept(%s) ... - CALLED!', $this->getVisitorInstance()));
// Visit the pool. This monitors the pool for incoming raw data.
$this->getListenerPoolInstance()->accept($this->getVisitorInstance());
$hasArrived = $this->isRawDataPending();
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: hasArrived=%d - EXIT!', intval($hasArrived)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: hasArrived=%d - EXIT!', intval($hasArrived)));
// Return the status
return $hasArrived;
} // END - if
// Very noisy debug message:
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Stacker size is ' . $this->getStackInstance()->getStackCount(self::STACKER_NAME_DECODED_INCOMING) . ' entries.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Stacker size is ' . $this->getStackInstance()->getStackCount(self::STACKER_NAME_DECODED_INCOMING) . ' entries.');
// "Pop" the next entry (the same array again) from the stack
$decodedData = $this->getStackInstance()->popNamed(self::STACKER_NAME_DECODED_INCOMING);
* Also make sure the error code is SOCKET_ERROR_UNHANDLED because we
* only want to handle unhandled packages here.
*/
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: errorCode=' . $decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE] . '(' . StorableSocket::SOCKET_ERROR_UNHANDLED . ')');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: errorCode=' . $decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE] . '(' . StorableSocket::SOCKET_ERROR_UNHANDLED . ')');
assert($decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE] == StorableSocket::SOCKET_ERROR_UNHANDLED);
// Remove the last chunk SEPARATOR (because there is no need for it)
} // END - if
// This package is "handled" and can be pushed on the next stack
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Pushing ' . strlen($decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes to stack ' . self::STACKER_NAME_DECODED_HANDLED . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Pushing ' . strlen($decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes to stack ' . self::STACKER_NAME_DECODED_HANDLED . ' ...');
$this->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_HANDLED, $decodedData);
}
$decodedData = $handlerInstance->getNextRawData();
// Very noisy debug message:
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: decodedData[' . gettype($decodedData) . ']=' . print_r($decodedData, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: decodedData[' . gettype($decodedData) . ']=' . print_r($decodedData, TRUE));
// And push it on our stack
$this->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_INCOMING, $decodedData);
$this->getStackInstance()->popNamed(self::STACKER_NAME_DECODED_HANDLED);
// ... and push it on the 'chunked' stacker
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Pushing ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes on stack ' . self::STACKER_NAME_DECODED_CHUNKED . ',packageContent=' . print_r($packageContent, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Pushing ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes on stack ' . self::STACKER_NAME_DECODED_CHUNKED . ',packageContent=' . print_r($packageContent, TRUE));
$this->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_CHUNKED, $packageContent);
}
*/
public function accept (Visitor $visitorInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: ' . $visitorInstance->__toString() . ' has visited - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: ' . $visitorInstance->__toString() . ' has visited - CALLED!');
// Visit the package
$visitorInstance->visitNetworkPackage($this);
$this->getAssemblerInstance()->accept($visitorInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: ' . $visitorInstance->__toString() . ' has visited - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: ' . $visitorInstance->__toString() . ' has visited - EXIT!');
}
/**
$this->initStacks(TRUE);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: All stacker have been re-initialized.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: All stacker have been re-initialized.');
}
/**
$messageArray[self::MESSAGE_ARRAY_DATA][self::MESSAGE_ARRAY_TYPE] = $messageArray[self::MESSAGE_ARRAY_TYPE];
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: messageArray=' . print_r($messageArray, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: messageArray=' . print_r($messageArray, TRUE));
// Create a handler instance from given message type
$handlerInstance = MessageTypeHandlerFactory::createMessageTypeHandlerInstance($messageArray[self::MESSAGE_ARRAY_TYPE]);
* @todo ~10% done?
*/
public function feedHashToMiner (array $messageData) {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: messageData()=%d - CALLED!', count($messageData)));
+
// Is the feature enabled?
if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) {
/*
unset($messageData[self::MESSAGE_ARRAY_DATA]);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: messageData=' . print_r($messageData, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: messageData=' . print_r($messageData, TRUE));
// Resolve session id ('sender' is a session id) into node id
$nodeId = HubTools::resolveNodeIdBySessionId($messageData[self::MESSAGE_ARRAY_SENDER]);
// Also remove tags as the miner don't need this.
unset($messageData[self::MESSAGE_ARRAY_TAGS]);
- $this->partialStub('@TODO nodeId=' . $nodeId . ',messageData=' . print_r($messageData, TRUE));
+ // Unfinished stuff:
+ $this->partialStub(sprintf('[%s:%d]: @TODO nodeId=%s,messageData=%s', __METHOD__, __LINE__, $nodeId, print_r($messageData, TRUE)));
}
}
assert(strlen($finalHash) > 0);
// Is the pointer already initialized?
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: finalHash[' . gettype($finalHash) . ']=' . $finalHash);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: finalHash[' . gettype($finalHash) . ']=' . $finalHash);
assert(isset($this->chunkPointers[$finalHash]));
// Return it
assert(isset($this->chunkPointers[$finalHash]));
// Count one up
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: finalHash[' . gettype($finalHash) . ']=' . $finalHash);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: finalHash[' . gettype($finalHash) . ']=' . $finalHash);
$this->chunkPointers[$finalHash]++;
}
$this->generateHashFromRawData($lastChunk);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: Adding EOP chunk with size of ' . strlen($chunkData) . ',finalHash=' . $finalHash . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: Adding EOP chunk with size of ' . strlen($chunkData) . ',finalHash=' . $finalHash . ' ...');
// Add it as regular chunk
$this->addChunkData($finalHash, $chunkData);
// Calculate real (data) chunk size
$dataChunkSize = $this->getDataChunkSizeFromHash($finalHash);
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: dataChunkSize=' . $dataChunkSize);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: dataChunkSize=' . $dataChunkSize);
// Init variables
$chunkHash = '';
} // END - for
// Debug output
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: Raw data of ' . strlen($rawData) . ' bytes has been fragmented into ' . count($this->chunks[$finalHash]) . ' chunk(s).');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: Raw data of ' . strlen($rawData) . ' bytes has been fragmented into ' . count($this->chunks[$finalHash]) . ' chunk(s).');
// Add end-of-package chunk
$this->appendEndOfPackageChunk($chunkData, $finalHash);
);
// Make sure the chunk is not larger than a TCP package can hold
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: assert: ' . strlen($rawData) . '/' . NetworkPackage::TCP_PACKAGE_SIZE . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: assert: ' . strlen($rawData) . '/' . NetworkPackage::TCP_PACKAGE_SIZE . ' ...');
// @TODO This assert broke packages where the hash chunk was very large: assert(strlen($rawData) <= NetworkPackage::TCP_PACKAGE_SIZE);
// Add it to the array
if ($prepend === TRUE) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: Prepending ' . strlen($rawData) . ' bytes of a chunk, finalHash=' . $finalHash . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: Prepending ' . strlen($rawData) . ' bytes of a chunk, finalHash=' . $finalHash . ' ...');
array_unshift($this->chunkHashes[$finalHash], $rawDataHash);
array_unshift($this->chunks[$finalHash] , $rawData);
} else {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: Appending ' . strlen($rawData) . ' bytes of a chunk, finalHash=' . $finalHash . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: Appending ' . strlen($rawData) . ' bytes of a chunk, finalHash=' . $finalHash . ' ...');
// Is the array there?
if (!isset($this->chunks[$finalHash])) {
assert($this->serialNumber[$finalHash] <= $this->maxSerialNumber);
// Encode the current serial number
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: serialNumber[' . $finalHash . ']=' . $this->serialNumber[$finalHash]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: serialNumber[' . $finalHash . ']=' . $this->serialNumber[$finalHash]);
$encodedSerialNumber = $this->dec2Hex($this->serialNumber[$finalHash], self::MAX_SERIAL_LENGTH);
// Count one up
$this->serialNumber[$finalHash]++;
// Return the encoded serial number
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: encodedSerialNumber=' . $encodedSerialNumber);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: encodedSerialNumber=' . $encodedSerialNumber);
return $encodedSerialNumber;
}
}
// Return final hash
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: finalHash[' . gettype($finalHash) . ']=' . $finalHash);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: finalHash[' . gettype($finalHash) . ']=' . $finalHash);
return $finalHash;
}
*/
public function getNextRawDataChunk ($finalHash) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: finalHash[' . gettype($finalHash) . ']=' . $finalHash);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: finalHash[' . gettype($finalHash) . ']=' . $finalHash);
try {
// Get current chunk index
// If there is no entry left, return an empty array
if ((!isset($this->chunkHashes[$finalHash][$current])) || (!isset($this->chunks[$finalHash][$current]))) {
// No more entries found
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__. ': finalHash=' . $finalHash . ',current=' . $current . ' - No more entries found!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__. ': finalHash=' . $finalHash . ',current=' . $current . ' - No more entries found!');
return array();
} // END - if
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__. ': finalHash=' . $finalHash . ',current=' . $current . ',chunkHashes()=' . count($this->chunkHashes[$finalHash]) .' - Entry choosen ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__. ': finalHash=' . $finalHash . ',current=' . $current . ',chunkHashes()=' . count($this->chunkHashes[$finalHash]) .' - Entry choosen ...');
// Generate the array
$rawDataChunk = array(
// Reset/set serial number
$this->serialNumber[$finalHash] = 0;
}
-}
-// [EOF]
-?>
+}
*/
protected final function addInstance ($group, $poolName, Visitable $visitableInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: group=' . $group . ',poolName=' . $poolName . ',visitableInstance=' . $visitableInstance->__toString() . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: group=' . $group . ',poolName=' . $poolName . ',visitableInstance=' . $visitableInstance->__toString() . ' - CALLED!');
// Make sure the group is not 'invalid'
assert($group != 'invalid');
$this->getPoolEntriesInstance()->addInstance($group, $poolName, $visitableInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: EXIT!');
}
/**
*/
public function accept (Visitor $visitorInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: ' . $visitorInstance->__toString() . ' has visited - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: ' . $visitorInstance->__toString() . ' has visited - CALLED!');
// Visit this pool
$visitorInstance->visitPool($this);
Registry::getRegistry()->addInstance($visitorInstance->getVisitorMode() . '_pool_iterator', $iteratorInstance);
}
- // Reset the counter
- $iteratorInstance->rewind();
+ // Is it valid?
+ if (!$iteratorInstance->valid()) {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: Rewinding iterator ...');
- // Visit all registered entries
- while ($iteratorInstance->valid()) {
- // Get current entry
- $poolEntry = $iteratorInstance->current();
+ // Rewind it
+ $iteratorInstance->rewind();
+ } // END - if
+
+ // Get current entry
+ $poolEntry = $iteratorInstance->current();
- // Is this entry visitable?
- if ($poolEntry instanceof Visitable) {
- // Visit this entry as well
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: Going to visit pooled object ' . $poolEntry->__toString() . ' with visitor ' . $visitorInstance->__toString() . ' ...');
- $poolEntry->accept($visitorInstance);
- } else {
- // Cannot visit this entry
- $this->partialStub('Pool entry with key ' . $iteratorInstance->key() . ' has improper type ' . gettype($poolEntry) . ', reason: not implementing Visitable.');
- }
+ // Is this entry visitable?
+ if ($poolEntry instanceof Visitable) {
+ // Visit this entry as well
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: Going to visit pooled object ' . $poolEntry->__toString() . ' with visitor ' . $visitorInstance->__toString() . ' ...');
+ $poolEntry->accept($visitorInstance);
+ } else {
+ // Cannot visit this entry
+ $this->partialStub('Pool entry with key ' . $iteratorInstance->key() . ' has improper type ' . gettype($poolEntry) . ', reason: not implementing Visitable.');
+ }
- // Advance to next entry
- $iteratorInstance->next();
- } // END - while
+ // Advance to next entry
+ $iteratorInstance->next();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: ' . $visitorInstance->__toString() . ' has visited - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: ' . $visitorInstance->__toString() . ' has visited - EXIT!');
}
/**
*/
public function preShutdown () {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: Shutting down listener pool - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: Shutting down listener pool - CALLED!');
// Get a new visitor
$visitorInstance = ObjectFactory::createObjectByConfiguredName('shutdown_listener_pool_visitor_class');
$this->accept($visitorInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: Shutting down listener pool - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: Shutting down listener pool - EXIT!');
}
/**
*/
public function generateListHashFromEntry (array $entry) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('POOL: entry()=%d - CALLED!', count($entry)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('POOL: entry()=%d - CALLED!', count($entry)));
// Debugging:
//* DEBUG-DIE: */ die(__METHOD__.':entry='.print_r($entry, TRUE));
}
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('POOL: hash[%s]=%s - EXIT!', gettype($hash), $hash));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('POOL: hash[%s]=%s - EXIT!', gettype($hash), $hash));
// Return hash
return $hash;
*/
public function addListener (Listenable $listenerInstance) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-LISTENER-POOL: listenerInstance=%s - CALLED!', $listenerInstance->__toString()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-LISTENER-POOL: listenerInstance=%s - CALLED!', $listenerInstance->__toString()));
// Add this listener instance to the instance list
parent::addInstance($listenerInstance->getProtocolName(), 'listener', $listenerInstance);
// Debug message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(
- 'DEFAULT-LISTENER-POOL: Listener ' . $listenerInstance->__toString() .
- ' with protocol ' . $listenerInstance->getProtocolName() .
- ' listening to ' . $listenerInstance->getListenAddress() . ':' .
- $listenerInstance->getListenPort() . ' added to listener pool.'
- );
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf(
+ 'DEFAULT-LISTENER-POOL: Listener %s with protocol %s listening to %s:%d added to listener pool.',
+ $listenerInstance->__toString(),
+ $listenerInstance->getProtocolName(),
+ $listenerInstance->getListenAddress(),
+ $listenerInstance->getListenPort()
+ ));
}
}
*/
private function validateSocket (StorableSocket $socketInstance) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-SYSTEM: socketInstance.socketResource=%s - CALLED!', $socketInstance->getSocketResource()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-SYSTEM: socketInstance.socketResource=%s - CALLED!', $socketInstance->getSocketResource()));
// Is it a valid resource?
if (!$socketInstance->isValidSocket()) {
*/
public function addPeer (StorableSocket $socketInstance, $connectionType) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ',connectionType=' . $connectionType . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ',connectionType=' . $connectionType . ' - CALLED!');
// Validate the socket
$this->validateSocket($socketInstance);
$peerPort = '0';
// Trace message
- /* NOSY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: Calling this->getListenerInstance() ...');
+ //* NOSY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: Calling this->getListenerInstance() ...');
// The socket resource should not match server socket
if (!$this->getListenerInstance()->getSocketInstance()->equals($socketInstance)) {
}
// Debug message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: Adding peer ' . $peerAddress . ':' . $peerPort . ',socketResource=' . $socketInstance->getSocketResource() . ',connectionType=' . $connectionType);
+ /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: Adding peer ' . $peerAddress . ':' . $peerPort . ',socketResource=' . $socketInstance->getSocketResource() . ',connectionType=' . $connectionType);
// Construct the array
$socketArray = array(
*/
public function getSocketFromPackageData (array $packageData, $connectionType = NULL) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL:packageData()=%d,connectionType[%s]=%s - CALLED!', count($packageData), gettype($connectionType), $connectionType));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL:packageData()=%d,connectionType[%s]=%s - CALLED!', count($packageData), gettype($connectionType), $connectionType));
// Default is no socket
$socketInstance = NULL;
$unlInstance = $handlerInstance->getUniversalNodeLocatorInstance();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: Checking ' . count($this->getAllSockets()) . ' socket(s),unlInstance.unl=' . $unlInstance->generateUnl() . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: Checking ' . count($this->getAllSockets()) . ' socket(s),unlInstance.unl=' . $unlInstance->generateUnl() . ' ...');
// Default is all sockets
$sockets = $this->getAllSockets();
// Get all sockets and check them, skip the server socket
foreach ($sockets as $socketArray) {
// Debugging:
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: socketArray(%d)=%s', count($socketArray), implode(',', $socketArray)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: socketArray(%d)=%s', count($socketArray), implode(',', $socketArray)));
//* DEBUG-DIE: */ die(__METHOD__.':connectionType='.$connectionType.',socketArray='.print_r($socketArray, TRUE));
// Is connection type set?
throw new InvalidConnectionTypeException(array($this, $connectionType), self::EXCEPTION_INVALID_CONNECTION_TYPE);
} elseif ((!empty($connectionType)) && ($socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE] !== $connectionType)) {
// Skip unwanted sockets
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: Skipping unwanted socket %s of type %s/%s ...', $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketResource(), $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE], $connectionType));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: Skipping unwanted socket %s of type %s/%s ...', $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketResource(), $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE], $connectionType));
continue;
}
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: socketInstance.socketResource=%s,socketInstance.socketProtocol=%s,socketArray[%s]=%s', $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketResource(), $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketProtocol(), Poolable::SOCKET_ARRAY_CONN_TYPE, $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE]));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: socketInstance.socketResource=%s,socketInstance.socketProtocol=%s,socketArray[%s]=%s', $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketResource(), $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketProtocol(), Poolable::SOCKET_ARRAY_CONN_TYPE, $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE]));
// Init peer address/port
$peerAddress = '0.0.0.0';
} // END - if
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: peerAddress=%s,peerPort=%d,unlInstance.addressPart=%s', $peerAddress, $peerPort, $unlInstance->getAddressPart()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: peerAddress=%s,peerPort=%d,unlInstance.addressPart=%s', $peerAddress, $peerPort, $unlInstance->getAddressPart()));
// If the "peer" IP and recipient is same, use it
if ($peerAddress == $unlInstance->getAddressPart()) {
$socketInstance = $socketArray[Poolable::SOCKET_ARRAY_INSTANCE];
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: peerAddress=%s matches with recipient IP address. Taking socketResource=%s,type=%s', $peerAddress, $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketResource(), $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE]));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: peerAddress=%s matches with recipient IP address. Taking socketResource=%s,type=%s', $peerAddress, $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketResource(), $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE]));
break;
} // END - if
} // END - foreach
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: socketInstance[]=' . gettype($socketInstance) . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: socketInstance[]=' . gettype($socketInstance) . ' - EXIT!');
// Return the determined socket instance
return $socketInstance;
*/
private function getSubRegistryKey (ShareableInfo $infoInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: infoInstance=' . $infoInstance->__toString() . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: infoInstance=' . $infoInstance->__toString() . ' - CALLED!');
// Get address and port
$address = $infoInstance->getAddress();
$port = $infoInstance->getPort();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: address=' . $address . ',port=' . $port);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: address=' . $address . ',port=' . $port);
// Get connection type and port number and add both together
$key = sprintf('%s:%s:%s:%s',
);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ' - EXIT!');
// Return resulting key
return $key;
*/
private function getRegistryKeyFromInfo (ShareableInfo $infoInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: this=' . $this->__toString() . ',infoInstance=' . $infoInstance->__toString() . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: this=' . $this->__toString() . ',infoInstance=' . $infoInstance->__toString() . ' - CALLED!');
// Get the key
$key = $infoInstance->getProtocolName();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ' - EXIT!');
// Return resulting key
return $key;
*/
private function isInfoRegistered (ShareableInfo $infoInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ' - CALLED!');
// Get the key
$key = $this->getRegistryKeyFromInfo($infoInstance);
$isRegistered = $this->instanceExists($key);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',isRegistered=' . intval($isRegistered) . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',isRegistered=' . intval($isRegistered) . ' - EXIT!');
// Return result
return $isRegistered;
*/
public function isSocketRegistered (ShareableInfo $infoInstance, StorableSocket $socketInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ' - CALLED!');
// Default is not registered
$isRegistered = FALSE;
$key = $this->getRegistryKeyFromInfo($infoInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: this=' . $this->__toString() . ',protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ',key=' . $key . ' - Trying to get instance ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: this=' . $this->__toString() . ',protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ',key=' . $key . ' - Trying to get instance ...');
// Get the registry
$registryInstance = $this->getInstance($key);
$socketKey = $this->getSubRegistryKey($infoInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: this=' . $this->__toString() . ',protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ',key=' . $key . ',socketKey=' . $socketKey . ' - Checking existence ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: this=' . $this->__toString() . ',protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ',key=' . $key . ',socketKey=' . $socketKey . ' - Checking existence ...');
// Is it there?
if ($registryInstance->instanceExists($socketKey)) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: Found instance for socketKey=' . $socketKey . ':' . $registryInstance->getInstance($socketKey));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: Found instance for socketKey=' . $socketKey . ':' . $registryInstance->getInstance($socketKey));
// Get the instance
$registeredInstance = $registryInstance->getInstance($socketKey);
$isRegistered = (($registeredInstance instanceof StorableSocket) && ($registeredInstance->equals($socketInstance)));
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: Final result: isRegistered(' . $socketInstance->getSocketResource() . ')=' . intval($isRegistered));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: Final result: isRegistered(' . $socketInstance->getSocketResource() . ')=' . intval($isRegistered));
} // END - if
} // END - if
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ',isRegistered=' . intval($isRegistered) . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ',isRegistered=' . intval($isRegistered) . ' - EXIT!');
// Return the result
return $isRegistered;
*/
public function registerSocketInstance (ShareableInfo $infoInstance, StorableSocket $socketInstance, array $packageData = array()) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ' - CALLED!');
// Is the socket already registered?
if ($this->isSocketRegistered($infoInstance, $socketInstance)) {
*/
public function getRegisteredSocketResource (Listenable $listenerInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY:listener=' . $listenerInstance->getProtocolName() . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY:listener=' . $listenerInstance->getProtocolName() . ' - CALLED!');
// The socket must be registered before we can return it
if (!$this->isInfoRegistered($listenerInstance)) {
$socketInstance = $registryInstance->getInstance($socketKey);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY:listener=' . $listenerInstance->getProtocolName() . ',socketResource[]=' . gettype($socketInstance) . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: listener=' . $listenerInstance->getProtocolName() . ',socketInstance[]=' . gettype($socketInstance) . ' - EXIT!');
// Return the resource
return $socketInstance;
// Get all keys and check them
foreach ($this->getInstanceRegistry() as $key => $registryInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ',registryInstance=' . $registryInstance->__toString());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ',registryInstance=' . $registryInstance->__toString());
// This is always a SubRegistry instance
foreach ($registryInstance->getInstanceRegistry() as $subKey => $socketInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ',subKey=' . $subKey . ',socketInstance=' . $socketInstance->__toString());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ',subKey=' . $subKey . ',socketInstance=' . $socketInstance->__toString());
// Is this a StorableSocket instance and is the address the same?
if (($socketInstance instanceof StorableSocket) && ($socketInstance->ifAddressMatches($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]))) {
//* DEBUG-DIE: */ die(__METHOD__ . ': socketInstance=' . print_r($socketInstance, TRUE));
// Trace message
- /* NOSY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: Calling socketInstance->getListenerInstance() ...');
+ //* NOSY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: Calling socketInstance->getListenerInstance() ...');
// Get listener and helper instances
$listenerInstance = $socketInstance->getListenerInstance();
$helperInstance = $socketInstance->getHelperInstance();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ',subKey=' . $subKey . ',listenerInstance[]=' . gettype($listenerInstance) . ',helperInstance[]=' . gettype($helperInstance));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ',subKey=' . $subKey . ',listenerInstance[]=' . gettype($listenerInstance) . ',helperInstance[]=' . gettype($helperInstance));
// Is a listener or helper set?
if ($listenerInstance instanceof Listenable) {
}
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ',subKey=' . $subKey . ',infoInstance[' . gettype($infoInstance) . ']=' . $infoInstance->__toString() . ' with protocol ' . $infoInstance->getProtocolName() . ' - FOUND!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ',subKey=' . $subKey . ',infoInstance[' . gettype($infoInstance) . ']=' . $infoInstance->__toString() . ' with protocol ' . $infoInstance->getProtocolName() . ' - FOUND!');
break;
} // END - if
} // END - foreach
} // END - if
} // END - foreach
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: infoInstance[]=' . gettype($infoInstance) . ' - EXIT!');
+
// Return the info instance
return $infoInstance;
}
* [[S]] - Start marker
* [[E]] - End marker
*/
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-OUTPUT-STREAM: data()=' . strlen($data) . ' - BEFORE!');
- $data = BaseRawDataHandler::STREAM_START_MARKER . base64_encode($data) . BaseRawDataHandler::STREAM_END_MARKER;
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-OUTPUT-STREAM: data(' . strlen($data) . ')=' . $data);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-OUTPUT-STREAM: data()=' . strlen($data) . ' - BEFORE!');
+ $data = sprintf('%s%s%s',
+ BaseRawDataHandler::STREAM_START_MARKER,
+ base64_encode($data),
+ BaseRawDataHandler::STREAM_END_MARKER
+ );
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-OUTPUT-STREAM: data(' . strlen($data) . ')=' . $data);
// Return it
return $data;
*/
public function accept (Visitor $visitorInstance) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-READER-TASK: visitorInstance=%s - CALLED!', $visitorInstance->__toString()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-READER-TASK: visitorInstance=%s - CALLED!', $visitorInstance->__toString()));
// Visit this task
$visitorInstance->visitTask($this);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: EXIT!');
}
/**
*/
public function executeTask () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: CALLED!');
// Get package instance
$packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-READER-TASK: packageInstance=%s', $packageInstance->__toString()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-READER-TASK: packageInstance=%s', $packageInstance->__toString()));
// Do we have something to handle?
if ($packageInstance->isProcessedMessagePending()) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->handleProcessedMessage() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->handleProcessedMessage() ...');
/*
* A previously proccessed message is waiting for being
$packageInstance->handleProcessedMessage();
} elseif ($packageInstance->isNewMessageArrived()) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->handleNewlyArrivedMessage() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->handleNewlyArrivedMessage() ...');
/*
* A fully "decoded" message has been received and added for being
$packageInstance->handleNewlyArrivedMessage();
} elseif ($packageInstance->isIncomingRawDataHandled()) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->assembleDecodedDataToPackage() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->assembleDecodedDataToPackage() ...');
/*
* Incoming decoded data has been handled (see below) so it needs to
$packageInstance->assembleDecodedDataToPackage();
} elseif ($packageInstance->ifMultipleMessagesPending()) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->handleMultipleMessages() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->handleMultipleMessages() ...');
/*
* Some raw data contained multiple messages which where now splitted.
$packageInstance->handleMultipleMessages();
} elseif ($packageInstance->isNewRawDataPending()) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->handleIncomingDecodedData() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->handleIncomingDecodedData() ...');
// Raw, decoded data has been received
$packageInstance->handleIncomingDecodedData();
} elseif ($packageInstance->ifAssemblerHasPendingDataLeft()) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->handleAssemblerPendingData() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->handleAssemblerPendingData() ...');
// Handle any pending data from the package assembler
$packageInstance->handleAssemblerPendingData();
}
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: EXIT!');
}
/**
*/
public function accept (Visitor $visitorInstance) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-WRITER-TASK: visitorInstance=%s - CALLED!', $visitorInstance->__toString()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-WRITER-TASK: visitorInstance=%s - CALLED!', $visitorInstance->__toString()));
// Visit this task
$visitorInstance->visitTask($this);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: EXIT!');
}
/**
*/
public function executeTask () {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: CALLED!');
// "Cache" package instance
$packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
// Do we have something to deliver?
if ($packageInstance->isEncodedDataPending()) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: Calling packageInstance->sendEncodedData() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: Calling packageInstance->sendEncodedData() ...');
// Sent encoded (raw) data
$packageInstance->sendEncodedData();
} elseif ($packageInstance->isPackageWaitingForDelivery()) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: Calling packageInstance->sendWaitingPackage() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: Calling packageInstance->sendWaitingPackage() ...');
// Sent it finally out
$packageInstance->sendWaitingPackage();
} elseif ($packageInstance->isPackageDeclared()) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: Calling packageInstance->processDeclaredPackage() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: Calling packageInstance->processDeclaredPackage() ...');
// Prepare package for delivery
$packageInstance->processDeclaredPackage();
} elseif ($packageInstance->isPackageEnqueued()) {
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: Calling packageInstance->declareEnqueuedPackage() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: Calling packageInstance->declareEnqueuedPackage() ...');
// Okay, then deliver (better discover its recipients) this package
$packageInstance->declareEnqueuedPackage();
}
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: EXIT!');
}
/**
$nodeInstance = NodeObjectFactory::createNodeInstance();
// Visit the pool listener task
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-TASK: Going to visit object ' . $nodeInstance->getListenerPoolInstance()->__toString() . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-TASK: Going to visit object ' . $nodeInstance->getListenerPoolInstance()->__toString() . ' ...');
$nodeInstance->getListenerPoolInstance()->accept($visitorInstance);
// Visit this task
$nodeData = DhtObjectFactory::createDhtInstance('node')->findNodeLocalBySessionId($sessionId);
// Make sure the node id is there
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: sessionId=' . $sessionId . ', nodeData[' . gettype($nodeData) . ']=' . print_r($nodeData, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: sessionId=' . $sessionId . ', nodeData[' . gettype($nodeData) . ']=' . print_r($nodeData, TRUE));
assert(isset($nodeData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_NODE_ID]));
// Return it
*/
public static function determineOwnInternalAddress () {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: CALLED!');
// Is the internal_address config entry set?
if (FrameworkConfiguration::getSelfInstance()->getConfigEntry('allow_publish_internal_address') == 'N') {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: Calling self::determineOwnExternalAddress() as allow_publish_internal_address=N is set ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: Calling self::determineOwnExternalAddress() as allow_publish_internal_address=N is set ...');
// Not allowed to publish internal address, so use external
$unl = self::determineOwnExternalAddress();
} elseif (FrameworkConfiguration::getSelfInstance()->getConfigEntry('internal_address') != '') {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: Getting config entry internal_address ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: Getting config entry internal_address ...');
// Use it as internal address
$unl = FrameworkConfiguration::getSelfInstance()->getConfigEntry('internal_address');
} else {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: Calling self::determineInternalUniversalNodeLocator() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: Calling self::determineInternalUniversalNodeLocator() ...');
// Determine own internal address
$unl = self::determineInternalUniversalNodeLocator();
}
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: unl=' . $unl . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: unl=' . $unl . ' - EXIT!');
// Return it
return $unl;
*/
public static function determineInternalUniversalNodeLocator () {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: CALLED!');
// Is there cache? (This shortens a lot calls)
if (!isset($GLOBALS[__METHOD__])) {
} // END - if
// Return it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!');
return $GLOBALS[__METHOD__];
}
*/
public static function determineExternalUniversalNodeLocator () {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: CALLED!');
// Is there cache? (This shortens a lot calls)
if (!isset($GLOBALS[__METHOD__])) {
} // END - if
// Return it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!');
return $GLOBALS[__METHOD__];
}
*/
public function visitPool (Poolable $poolInstance) {
// A pool doesn't normally have any raw data waiting
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAWDATA-MONITOR-VISITOR: poolInstance=' . $poolInstance->__toString() . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAWDATA-MONITOR-VISITOR: poolInstance=' . $poolInstance->__toString() . ' - CALLED!');
}
/**
* traffic. This is why its method monitorIncomingRawData() is not
* called.
*/
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAWDATA-MONITOR-VISITOR: listenerInstance=' . $listenerInstance->__toString() . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAWDATA-MONITOR-VISITOR: listenerInstance=' . $listenerInstance->__toString() . ' - CALLED!');
}
/**
*/
public function visitDecorator (BaseDecorator $decoratorInstance) {
// Do monitor here
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAWDATA-MONITOR-VISITOR: Visiting decoratorInstance=' . $decoratorInstance->__toString() . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAWDATA-MONITOR-VISITOR: Visiting decoratorInstance=' . $decoratorInstance->__toString() . ' - CALLED!');
$decoratorInstance->monitorIncomingRawData();
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAWDATA-MONITOR-VISITOR: Visiting decoratorInstance=' . $decoratorInstance->__toString() . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAWDATA-MONITOR-VISITOR: Visiting decoratorInstance=' . $decoratorInstance->__toString() . ' - EXIT!');
}
}
*/
public function visitPool (Poolable $poolInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $poolInstance->__toString() . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $poolInstance->__toString() . ' - CALLED!');
// Pre-shutdown the pool
$poolInstance->preShutdown();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $poolInstance->__toString() . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $poolInstance->__toString() . ' - EXIT!');
}
/**
*/
public function visitDecorator (Listenable $decoratorInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $decoratorInstance->__toString() . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $decoratorInstance->__toString() . ' - CALLED!');
// Pre-shutdown the pool
$decoratorInstance->doShutdown();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $decoratorInstance->__toString() . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $decoratorInstance->__toString() . ' - EXIT!');
}
/**
*/
public function visitListener (Listenable $listenerInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $listenerInstance->__toString() . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $listenerInstance->__toString() . ' - CALLED!');
// Pre-shutdown the pool
$listenerInstance->doShutdown();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $listenerInstance->__toString() . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $listenerInstance->__toString() . ' - EXIT!');
}
-}
-//
-?>
+}
*/
public function visitTask (Taskable $taskInstance) {
// Execute the task from this visitor
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ACTIVE-TASK-VISITOR: Visiting task ' . $taskInstance->__toString() . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ACTIVE-TASK-VISITOR: Visiting task ' . $taskInstance->__toString() . ' - CALLED!');
$taskInstance->executeTask();
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ACTIVE-TASK-VISITOR: Visiting task ' . $taskInstance->__toString() . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ACTIVE-TASK-VISITOR: Visiting task ' . $taskInstance->__toString() . ' - EXIT!');
}
/**
* @return void
*/
public function visitPool (Poolable $poolInstance) {
- /**
- * We don't need to visit a pool as an active task because a pool can
- * never become a task. Instead e.g. by a listener pool we should visit
- * all listeners one by one
+ /*
+ * No need to visit a pool as an active task because a pool can never
+ * become a task. Instead visit all pool members one-by-one.
*/
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('ACTIVE-TASK-VISITOR: poolInstance=%s - CALLED!', $poolInstance->__toString()));
}
/**
*/
public function visitListener (Listenable $listenerInstance) {
// Do "listen" here
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ACTIVE-TASK-VISITOR: Visiting listenerInstance=' . $listenerInstance->__toString() . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ACTIVE-TASK-VISITOR: Visiting listenerInstance=' . $listenerInstance->__toString() . ' - CALLED!');
$listenerInstance->doListen();
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ACTIVE-TASK-VISITOR: Visiting listenerInstance=' . $listenerInstance->__toString() . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ACTIVE-TASK-VISITOR: Visiting listenerInstance=' . $listenerInstance->__toString() . ' - EXIT!');
}
/**
* @return void
*/
public function visitDecorator (BaseDecorator $decoratorInstance) {
- // A decorator itself can never become an active task so this method
- // remains empty.
+ /*
+ * A decorator itself can never become an active task so this method
+ * remains empty.
+ */
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('ACTIVE-TASK-VISITOR: decoratorInstance=%s - CALLED!', $decoratorInstance->__toString()));
}
}
namespace Hub\Information;
// Import application-specific stuff
+use Hub\Container\Socket\StorableSocket;
use Hub\Helper\Connection\ConnectionHelper;
use Hub\Listener\Listenable;
*/
function fillWithConnectionHelperInformation (ConnectionHelper $helperInstance);
+ /**
+ * Fills the information class with peer data from given socket instance
+ *
+ * @param $socketInstance An instance of a StorableSocket class
+ * @return void
+ */
+ function fillWithSocketPeerInformation (StorableSocket $socketInstance);
+
}
-Subproject commit fc0b718d5c258e187b226e2a088769e5d14fcc1f
+Subproject commit e72033bed456c820815feeb2d25335245499448e