From d5b9867bed1f93472a6d49777eab34619a01161c Mon Sep 17 00:00:00 2001 From: Matthieu Racine Date: Sun, 3 Mar 2019 14:40:08 +0100 Subject: [PATCH] Fix #3: Add test on responses count when login, try with legacy=true when multiple responses --- src/Client.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Client.php b/src/Client.php index 85afe6b..c9c67df 100644 --- a/src/Client.php +++ b/src/Client.php @@ -385,8 +385,18 @@ class Client implements Interfaces\ClientInterface // Execute query and get response $response = $this->write($query)->read(false); + // if : + // - we have more than one response + // - response is '!done' + // => problem with legacy version, swap it and retry + // Only tested with ROS pre 6.43, will test with post 6.43 => this could make legacy parameter obsolete ? + if (count($response)>1 && $response[0] === '!done' && !$this->config('legacy')) + { + $this->_config->set('legacy', true); + return $this->login(); + } // Return true if we have only one line from server and this line is !done - return isset($response[0]) && $response[0] === '!done'; + return (1 === count($response)) && isset($response[0]) && ($response[0] === '!done'); } /**