From 33020edeb032b12c523a6b0da4010b5d20fd0deb Mon Sep 17 00:00:00 2001 From: Baudev Date: Tue, 21 May 2019 17:08:04 +0200 Subject: [PATCH] Remove empty value to avoid keep alive exchange after each received message --- src/Core.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Core.php b/src/Core.php index 51e7469..031ce40 100644 --- a/src/Core.php +++ b/src/Core.php @@ -187,7 +187,11 @@ public function stream() // we set an infinite loop while (($packetData = $this->read($this->getRemote())) !== 1) { // we explode the packet after each footer node - $packetArray = preg_split('/(?<=<\/message>)/', $packetData, -1); + $packetArray = preg_split('/(?<=<\/message>)/', $packetData, null); // we keep empty value for Keep alive exchange + $nbr = count($packetArray); + if($nbr > 1 && $packetArray[$nbr - 1] == null){ // remove last empty value to avoid keep alive exchange after each message + unset($packetArray[$nbr - 1]); + } foreach ($packetArray as $packet) { // make sure that the XML received is well formatted $validXML = $this->analyzeData($packet);