Skip to content

Commit

Permalink
Merge pull request #9 from baudev/hotfixes
Browse files Browse the repository at this point in the history
Remove some useless keep alive exchanges
  • Loading branch information
baudev authored May 21, 2019
2 parents 1ba7ff8 + 33020ed commit bda0c11
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit bda0c11

Please sign in to comment.