From 98fb6911dae3587333c183c6552a54f6f27eb50e Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 15 Mar 2014 00:59:01 +0100 Subject: [PATCH] Added unfinished stuff for multiple messages. Signed-off-by: Roland Haeder --- .../package/assembler/class_Assembler.php | 14 +++++++++++ .../interfaces/package/class_Receivable.php | 14 +++++++++++ .../assembler/class_PackageAssembler.php | 23 +++++++++++++++++++ .../hub/main/package/class_NetworkPackage.php | 23 +++++++++++++++++++ .../class_NetworkPackageReaderTask.php | 5 ++++ 5 files changed, 79 insertions(+) diff --git a/application/hub/interfaces/package/assembler/class_Assembler.php b/application/hub/interfaces/package/assembler/class_Assembler.php index 0cf5d9fe8..b87a91992 100644 --- a/application/hub/interfaces/package/assembler/class_Assembler.php +++ b/application/hub/interfaces/package/assembler/class_Assembler.php @@ -45,6 +45,20 @@ interface Assembler extends FrameworkInterface { * @return void */ function handlePendingData (); + + /** + * Checks whether the assembler has multiple messages pending + * + * @return $isPending Whether the assembler has multiple messages pending + */ + function ifMultipleMessagesPending (); + + /** + * Handles multiple messages. + * + * @return void + */ + function handleMultipleMessages (); } // [EOF] diff --git a/application/hub/interfaces/package/class_Receivable.php b/application/hub/interfaces/package/class_Receivable.php index 33bd24c1f..55e081b5f 100644 --- a/application/hub/interfaces/package/class_Receivable.php +++ b/application/hub/interfaces/package/class_Receivable.php @@ -121,6 +121,20 @@ interface Receivable extends FrameworkInterface { * @return void */ function handleRawData (array $decodedData); + + /** + * Checks whether the assembler has multiple messages pending + * + * @return $isPending Whether the assembler has multiple messages pending + */ + function ifMultipleMessagesPending (); + + /** + * Handles multiple messages. + * + * @return void + */ + function handleMultipleMessages (); } // [EOF] diff --git a/application/hub/main/package/assembler/class_PackageAssembler.php b/application/hub/main/package/assembler/class_PackageAssembler.php index 2325b9f99..263300aa0 100644 --- a/application/hub/main/package/assembler/class_PackageAssembler.php +++ b/application/hub/main/package/assembler/class_PackageAssembler.php @@ -194,6 +194,29 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, return $ifPendingDataIsEmpty; } + /** + * Checks whether the assembler has multiple messages pending + * + * @return $isPending Whether the assembler has multiple messages pending + */ + public function ifMultipleMessagesPending () { + // Determine it + $isPending = (!$this->getStackerInstance()->isStackEmpty(self::STACKER_NAME_MULTIPLE_MESSAGE); + + // Return it + return $isPending; + } + + /** + * Handles multiple messages. + * + * @return void + * @todo 0% done + */ + public function handleMultipleMessages () { + $this->partialStub('Unfinished method.'); + } + /** * Handles the assembler's pending data * diff --git a/application/hub/main/package/class_NetworkPackage.php b/application/hub/main/package/class_NetworkPackage.php index faf9f1703..d6ee7e20d 100644 --- a/application/hub/main/package/class_NetworkPackage.php +++ b/application/hub/main/package/class_NetworkPackage.php @@ -1009,6 +1009,19 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R return $isHandled; } + /** + * Checks whether the assembler has multiple packages pending + * + * @return $isPending Whether the assembler has multiple packages pending + */ + public function ifMultipleMessagesPending () { + // Determine if the stack is not empty + $isPending = (!$this->getAssemblerInstance()->ifMultipleMessagesPending()); + + // Return it + return $isPending; + } + /** * Handles the attached assemler's pending data queue to be finally * assembled to the raw package data back. @@ -1020,6 +1033,16 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $this->getAssemblerInstance()->handlePendingData(); } + /** + * Handles multiple messages. + * + * @return void + */ + public function handleMultipleMessages () { + // Handle it + $this->getAssemblerInstance()->handleMultipleMessages(); + } + /** * Assembles incoming decoded data so it will become an abstract network * package again. The assembler does later do it's job by an other task, diff --git a/application/hub/main/tasks/network/class_NetworkPackageReaderTask.php b/application/hub/main/tasks/network/class_NetworkPackageReaderTask.php index 98386f015..820a0d9ac 100644 --- a/application/hub/main/tasks/network/class_NetworkPackageReaderTask.php +++ b/application/hub/main/tasks/network/class_NetworkPackageReaderTask.php @@ -100,6 +100,11 @@ class NetworkPackageReaderTask extends BaseTask implements Taskable, Visitable { * for further details (what array elements are required et cetera). */ $packageInstance->assembleDecodedDataToPackage(); + } elseif ($packageInstance->ifMultipleMessagesPending()) { + /* + * Some raw data contained multiple messages which where now splitted. + */ + $packageInstance->handleMultipleMessages(); } elseif ($packageInstance->isNewRawDataPending($this->getListenerPoolInstance())) { // Raw, decoded data has been received $packageInstance->handleIncomingDecodedData(); -- 2.39.5