]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/listener/class_BaseListenerDecorator.php
Handling of decoded raw data continued:
[hub.git] / application / hub / main / listener / class_BaseListenerDecorator.php
index e71c66f7ca3731f5587383a129faeb932a4648e7..e102c530e30a0276688625c96c87c1ba8a7acfad 100644 (file)
@@ -110,7 +110,7 @@ class BaseListenerDecorator extends BaseDecorator implements Visitable {
        /**
         * Getter for peer pool instance
         *
-        * @return      $poolInstance   The peer pool instance we shall set
+        * @return      $poolInstance   A peer pool instance
         */
        public final function getPoolInstance () {
                return $this->getListenerInstance()->getPoolInstance();
@@ -124,16 +124,34 @@ class BaseListenerDecorator extends BaseDecorator implements Visitable {
         * @return      void
         */
        public function monitorIncomingRawData (Receivable $receiverInstance) {
+               // Get the handler instance
+               $handlerInstance = $this->getListenerInstance()->getHandlerInstance();
+
                /*
                 * Does our deocorated listener (or even a decorator again) have a
                 * handler assigned? Remember that a handler will hold all incoming raw
                 * data and not a listener.
                 */
-               if (!$this->getListenerInstance()->getHandlerInstance() instanceof Networkable) {
+               if (!$handlerInstance instanceof Networkable) {
                        // Skip this silently for now. Later on, this will become mandatory!
                        //* NOISY-DEBUG: */ $this->debugOutput('No handler assigned to this listener decorator. this=' . $this->__toString() . ', listenerInstance=' . $this->getListenerInstance()->__toString());
                        return;
                } // END - if
+
+               // Does the handler have some decoded data pending?
+               if (!$handlerInstance->isDecodedDataPending()) {
+                       // No data is pending so skip further code silently
+                       return;
+               } // END - if
+
+               /*
+                * We have some pending decoded data. The receiver instance is an
+                * abstract network package (which can be received and sent out) so
+                * handle the decoded data over. At this moment we don't need to know
+                * if the decoded data origins from a TCP or UDP connection so we can
+                * just pass it over to the network package receiver
+                */
+               $receiverInstance->addDecodedDataToIncomingStack($handlerInstance);
        }
 }