Also, have a look at ESP8266WiFi/examples/WiFiTelnetToSerial example, but instead of outputting to serial accumulate the characters received into a buffer until new line and then execute your command parsing on that buffer.
Also, have a look at ESP8266WiFi/examples/WiFiTelnetToSerial example, but instead of outputting to serial accumulate the characters received into a buffer until new line and then execute your command parsing on that buffer.