…ring). Signed-off-by: Nick D'Ademo <email@example.com>
EthernetClient will stay connected() as long as data is available(), but WiFiClient() can switch to !connected() while there are still data unread in its buffer and therefore available(). Therefore, let's check for available() when reading data rather than connected().
The original parser does not cope gracefully with input that is not proper json. Try sending "Hi there" to any of the library examples and see the results. This commit adds two things: - the "getch" method now times out after 500ms. This removes the situation whereby the parser got often stuck waiting forever on malformed input. - A new "flush" method is added, because the parser leaves the input buffer untouched in case it cannot understand the contents, which means that it will get stuck forever again trying to parse the same input if we try several times.