]> git.mxchange.org Git - hub.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 26 Feb 2023 08:44:09 +0000 (09:44 +0100)
committerRoland Häder <roland@mxchange.org>
Sun, 26 Feb 2023 08:44:09 +0000 (09:44 +0100)
- introduced NetworkMessage class
- NetworkMessageFactory now has a "static initializer"
- lesser deprecated debugOutput()

application/hub/classes/factories/network/message/class_NetworkMessageFactory.php
application/hub/classes/factories/socket/class_SocketFactory.php
application/hub/classes/message/class_NetworkMessage.php [new file with mode: 0644]

index 58a92a4653201cfd722ba2517100b7fefc931b59..4c8c3f8978cc37409c42db86d4469bd10af273fb 100644 (file)
@@ -33,6 +33,11 @@ use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class NetworkMessageFactory extends BaseFactory {
+       /**
+        * "Cache" for message factory
+        */
+       private static $messageFactoryInstance = NULL;
+
        /**
         * Protected constructor
         *
@@ -43,6 +48,23 @@ class NetworkMessageFactory extends BaseFactory {
                parent::__construct(__CLASS__);
        }
 
+       /**
+        * Some "static initializer
+        *
+        * @return      void
+        */
+       public final static function staticInitializer () {
+               // Is it initialized?
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-MESSAGE-FACTORY: self::messageFactoryInstance[]=%s - CALLED!', gettype(self::$messageFactoryInstance)));
+               if (is_null(self::$messageFactoryInstance)) {
+                       // No, then initialize it
+                       self::$messageFactoryInstance = ObjectRegistry::getRegistry('factory');
+               }
+
+               // Trace message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-MESSAGE-FACTORY: self::messageFactoryInstance=%s - EXIT!', self::$messageFactoryInstance));
+       }
+
        /**
         * Returns a singleton (registry-based) DeliverableMessage instance
         *
@@ -50,12 +72,15 @@ class NetworkMessageFactory extends BaseFactory {
         * @return      $messageInstance        An instance of a DeliverableMessage class
         */
        public static final function createNetworkMessageInstanceFromPackage (DeliverablePackage $packageInstance) {
-               // If there is no handler?
+               // Invoke static initializer
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-MESSAGE-FACTORY: packageInstance=%s - CALLED!', $packageInstance->__toString()));
-               if (ObjectRegistry::getRegistry('factory')->instanceExists('network_message')) {
+               self::staticInitializer();
+
+               // If there is no handler?
+               if (self::$messageFactoryInstance->instanceExists('network_message')) {
                        // Get handler from registry
                        /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('NETWORK-MESSAGE-FACTORY: Getting messageInstance from registry ...');
-                       $messageInstance = ObjectRegistry::getRegistry('factory')->getInstance('network_message');
+                       $messageInstance = self::$messageFactoryInstance->getInstance('network_message');
                } else {
                        // Get the handler instance
                        /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('NETWORK-MESSAGE-FACTORY: Creating new messageInstance ...');
@@ -63,9 +88,13 @@ class NetworkMessageFactory extends BaseFactory {
 
                        // Add it to the registry
                        /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-MESSAGE-FACTORY: Adding messageInstance=%s to registy ...', $messageInstance->__toString()));
-                       ObjectRegistry::getRegistry('factory')->addInstance('network_message', $messageInstance);
+                       self::$messageFactoryInstance->addInstance('network_message', $messageInstance);
                }
 
+               // Parse package instance's XML
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-MESSAGE-FACTORY: Invoking messageInstance->parsePackageXmlToMessageFields(=%s) ...', $packageInstance->__toString()));
+               $messageInstance->parsePackageXmlToMessageFields($packageInstance);
+
                // Return the instance
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-MESSAGE-FACTORY: messageInstance=%s - EXIT!', $messageInstance->__toString()));
                return $messageInstance;
index df1381ad6f4c81a6c582c39dbe7d19a7eac7c641..a4f72de27080edf530589dd27be5821783b27f9c 100644 (file)
@@ -70,14 +70,14 @@ class SocketFactory extends BaseFactory {
         */
        public final static function staticInitializer () {
                // Is it initialized?
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: self::socketFactoryInstance[]=%s - CALLED!', gettype(self::$socketFactoryInstance)));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SOCKET-FACTORY: self::socketFactoryInstance[]=%s - CALLED!', gettype(self::$socketFactoryInstance)));
                if (is_null(self::$socketFactoryInstance)) {
                        // No, then initialize it
                        self::$socketFactoryInstance = ObjectRegistry::getRegistry('factory');
                }
 
                // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: self::socketFactoryInstance=%s - EXIT!', self::$socketFactoryInstance));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SOCKET-FACTORY: self::socketFactoryInstance=%s - EXIT!', self::$socketFactoryInstance));
        }
 
        /**
@@ -89,7 +89,7 @@ class SocketFactory extends BaseFactory {
         */
        public static function createSocketFromPackageInstance (DeliverablePackage $packageInstance, HandleableProtocol $protocolInstance) {
                // Invoke static initializer
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: packageInstance=%s,protocolInstance=%s - CALLED!', $packageInstance->__toString(), $protocolInstance->__toString()));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SOCKET-FACTORY: packageInstance=%s,protocolInstance=%s - CALLED!', $packageInstance->__toString(), $protocolInstance->__toString()));
                self::staticInitializer();
 
                // Init instance
@@ -103,13 +103,13 @@ class SocketFactory extends BaseFactory {
                );
 
                // Is the key there?
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: Trying to find a socket with registryKey=%s', $registryKey));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('SOCKET-FACTORY: Trying to find a socket with registryKey=%s', $registryKey));
                if (self::$socketFactoryInstance->instanceExists($registryKey)) {
                        // Get container instance
                        $socketInstance = self::$socketFactoryInstance->getInstance($registryKey);
 
                        // Debug message
-                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: Using socketResource[%s]=%s from registry.', gettype($socketInstance->getSocketResource()), $socketInstance->getSocketResource()));
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('SOCKET-FACTORY: Using socketResource[%s]=%s from registry.', gettype($socketInstance->getSocketResource()), $socketInstance->getSocketResource()));
                } else {
                        // Invoke inner factory
                        $socketInstance = ObjectFactory::createObjectByConfiguredName(sprintf('%s_connection_helper_class', $protocolInstance->getProtocolName()), array($packageInstance));
@@ -118,11 +118,11 @@ class SocketFactory extends BaseFactory {
                        self::$socketFactoryInstance->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__)->debugMessage('SOCKET-FACTORY: Socket is now registered in registry.');
                }
 
                // Return the socket (container) instance
-               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString()));
+               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString()));
                return $socketInstance;
        }
 
@@ -136,7 +136,7 @@ class SocketFactory extends BaseFactory {
         */
        public static final function createListenFileSocket (Listenable $listenerInstance) {
                // Create SplFileInfo
-               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: listenerInstance=%s - CALLED!', $listenerInstance->__toString()));
+               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SOCKET-FACTORY: listenerInstance=%s - CALLED!', $listenerInstance->__toString()));
                $fileInfo = new SplFileInfo(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('ipc_socket_file_name'));
 
                // Create file name
@@ -146,7 +146,7 @@ class SocketFactory extends BaseFactory {
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: socketFile=' . $socketFile . ' ...');
                if (empty($socketFile)) {
                        // Something unexpected
-                       throw new UnexpectedValueException('socketFile is empty');
+                       throw new UnexpectedValueException('socketFile is empty', FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
                }
 
                // Init package instance
@@ -167,7 +167,7 @@ class SocketFactory extends BaseFactory {
                $socketInstance->setSocketFile($socketFile);
 
                // Is the socket resource valid?
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance[]=%s', gettype($socketInstance)));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('SOCKET-FACTORY: socketInstance[]=%s', gettype($socketInstance)));
                if (!$socketInstance->isValidSocket()) {
                        // Something bad happened
                        throw new InvalidSocketException(array($listenerInstance, $socketInstance->getSocketResource()), self::EXCEPTION_INVALID_SOCKET);
@@ -182,7 +182,7 @@ class SocketFactory extends BaseFactory {
                // Is the file there?
                if ((FrameworkBootstrap::isReachableFilePath($socketInstance->getSocketFile())) && (file_exists($socketInstance->getSocketFile()))) {
                        // Old socket found
-                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: WARNING: Old socket at ' . $socketInstance->getSocketFile() . ' found. Will not start.');
+                       self::createDebugInstance(__CLASS__, __LINE__)->warningMessage('SOCKET-FACTORY: WARNING: Old socket at ' . $socketInstance->getSocketFile() . ' found. Will not start.');
 
                        // Shutdown this socket
                        $socketInstance->shutdownSocket();
@@ -192,28 +192,28 @@ class SocketFactory extends BaseFactory {
                }
 
                // Try to bind to it
-               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Binding to ' . $socketInstance->getSocketFile() . ' ...');
+               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('SOCKET-FACTORY: Binding to ' . $socketInstance->getSocketFile() . ' ...');
                if (!$socketInstance->bindSocketToFile()) {
                        // Handle error here
                        $socketInstance->handleSocketError(__METHOD__, __LINE__);
                }
 
                // Start listen for connections
-               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Listening for connections.');
+               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('SOCKET-FACTORY: Listening for connections.');
                if (!$socketInstance->listenToSocket()) {
                        // Handle this socket error
                        $socketInstance->handleSocketError(__METHOD__, __LINE__);
                }
 
                // Allow non-blocking I/O
-               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Setting non-blocking mode.');
+               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('SOCKET-FACTORY: Setting non-blocking mode.');
                if (!$socketInstance->enableSocketNonBlocking()) {
                        // Handle this socket error
                        $socketInstance->handleSocketError(__METHOD__, __LINE__);
                }
 
                // Return socket instance
-               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString()));
+               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString()));
                return $socketInstance;
        }
 
@@ -228,11 +228,11 @@ class SocketFactory extends BaseFactory {
         */
        public static final function createTcpOutgoingSocketFromPackageInstance (DeliverablePackage $packageInstance) {
                // Create a socket instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: packageInstance=%s - CALLED!', $packageInstance->__toString()));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SOCKET-FACTORY: packageInstance=%s - CALLED!', $packageInstance->__toString()));
                $socketResource = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
 
                // Construct container class, this won't be reached if an exception is thrown
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: Created socketResource[%s]=%s ...', gettype($socketResource), $socketResource));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('SOCKET-FACTORY: Created socketResource[%s]=%s ...', gettype($socketResource), $socketResource));
                $socketInstance = ObjectFactory::createObjectByConfiguredName('socket_container_class', [
                        $socketResource,
                        StorableSocket::SOCKET_PROTOCOL_TCP,
@@ -257,7 +257,7 @@ class SocketFactory extends BaseFactory {
                }
 
                // Set the option to reuse the port
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Enabling re-use address ...');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('SOCKET-FACTORY: Enabling re-use address ...');
                if (FrameworkBootstrap::getConfigurationInstance()->isEnabled('tcp_socket_enable_reuse_address') && !$socketInstance->enableSocketReuseAddress()) {
                        // Handle this socket error
                        $socketInstance->handleSocketError(__METHOD__, __LINE__);
@@ -268,14 +268,14 @@ class SocketFactory extends BaseFactory {
                 * it. This is now the default behaviour for all connection helpers who
                 * call initConnection(); .
                 */
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Setting non-blocking mode.');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('SOCKET-FACTORY: Setting non-blocking mode.');
                if (!$socketInstance->enableSocketNonBlocking()) {
                        // Handle this socket error
                        $socketInstance->handleSocketError(__METHOD__, __LINE__);
                }
 
                // Return it
-               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString()));
+               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString()));
                return $socketInstance;
        }
 
@@ -288,7 +288,7 @@ class SocketFactory extends BaseFactory {
         */
        public static function createListenTcpSocket (Listenable $listenerInstance) {
                // Create a streaming socket, of type TCP/IP
-               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: listenerInstance=%s - CALLED!', $listenerInstance->__toString()));
+               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SOCKET-FACTORY: listenerInstance=%s - CALLED!', $listenerInstance->__toString()));
                $socketResource = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
 
                // Init fake "package" instance, the SocketContainer class requires this
@@ -318,7 +318,7 @@ class SocketFactory extends BaseFactory {
                }
 
                // Set the option to reuse the port
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Enabling re-use address ...');
+               self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('SOCKET-FACTORY: Enabling re-use address ...');
                if (!$socketInstance->enableSocketReuseAddress()) {
                        // Handle this socket error
                        $socketInstance->handleSocketError(__METHOD__, __LINE__);
@@ -329,28 +329,28 @@ class SocketFactory extends BaseFactory {
                 * that all connections on this port are now our resposibility to
                 * send/recv data, disconnect, etc..
                 */
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Binding to address ' . $listenerInstance->getListenAddress() . ':' . $listenerInstance->getListenPort());
+               self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('SOCKET-FACTORY: Binding to address ' . $listenerInstance->getListenAddress() . ':' . $listenerInstance->getListenPort());
                if (!$socketInstance->bindSocketToListener()) {
                        // Handle this socket error
                        $socketInstance->handleSocketError(__METHOD__, __LINE__);
                }
 
                // Start listen for connections
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Listening for connections.');
+               self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('SOCKET-FACTORY: Listening for connections.');
                if (!$socketInstance->listenToSocket()) {
                        // Handle this socket error
                        $socketInstance->handleSocketError(__METHOD__, __LINE__);
                }
 
                // Now, we want non-blocking mode
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Setting non-blocking mode.');
+               self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('SOCKET-FACTORY: Setting non-blocking mode.');
                if (!$socketInstance->enableSocketNonBlocking()) {
                        // Handle this socket error
                        $socketInstance->handleSocketError(__METHOD__, __LINE__);
                }
 
                // Return prepepared socket
-               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString()));
+               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString()));
                return $socketInstance;
        }
 
@@ -363,7 +363,7 @@ class SocketFactory extends BaseFactory {
         */
        public static function createListenUdpSocket (Listenable $listenerInstance) {
                // Create a streaming socket, of type UDP
-               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: listenerInstance=%s - CALLED!', $listenerInstance->__toString()));
+               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SOCKET-FACTORY: listenerInstance=%s - CALLED!', $listenerInstance->__toString()));
                $socketResource = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
 
                // Init fake package instance
@@ -393,7 +393,7 @@ class SocketFactory extends BaseFactory {
                }
 
                // Set the option to reuse the port
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Enabling re-use address ...');
+               self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('SOCKET-FACTORY: Enabling re-use address ...');
                if (!$socketInstance->enableSocketReuseAddress()) {
                        // Handle this socket error
                        $socketInstance->handleSocketError(__METHOD__, __LINE__);
@@ -404,21 +404,21 @@ class SocketFactory extends BaseFactory {
                 * that all connections on this port are now our resposibility to
                 * send/recv data, disconnect, etc..
                 */
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Binding to address ' . $listenerInstance->getListenAddress() . ':' . $listenerInstance->getListenPort());
+               self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('SOCKET-FACTORY: Binding to address ' . $listenerInstance->getListenAddress() . ':' . $listenerInstance->getListenPort());
                if (!$socketInstance->bindSocketToListener()) {
                        // Handle this socket error
                        $socketInstance->handleSocketError(__METHOD__, __LINE__);
                }
 
                // Now, we want non-blocking mode
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Setting non-blocking mode.');
+               self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('SOCKET-FACTORY: Setting non-blocking mode.');
                if (!$socketInstance->enableSocketNonBlocking()) {
                        // Handle this socket error
                        $socketInstance->handleSocketError(__METHOD__, __LINE__);
                }
 
                // Return prepepared socket
-               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString()));
+               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString()));
                return $socketInstance;
        }
 
diff --git a/application/hub/classes/message/class_NetworkMessage.php b/application/hub/classes/message/class_NetworkMessage.php
new file mode 100644 (file)
index 0000000..2b07d52
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+// Own namespace
+namespace Org\Shipsimu\Hub\Network\Message;
+
+// Import application-specific stuff
+use Org\Shipsimu\Hub\Generic\BaseHubSystem;
+
+// Import framework-specific stuff
+use Org\Mxchange\CoreFramework\Registry\Registerable;
+
+/**
+ * A NetworkMessage
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class NetworkMessage extends BaseHubSystem implements DeliverableMessage, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       private function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $messageInstance        An instance of a DeliverableMessage class
+        */
+       public final static function createNetworkMessage () {
+               // Get new instance
+               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-MESSAGE: CALLED!');
+               $messageInstance = new NetworkMessage();
+
+               // Return the prepared instance
+               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-MESSAGE: messageInstance=%s - EXIT!', $messageInstance->__toString()));
+               return $messageInstance;
+       }
+
+}