I’m stuck on Stage #( Build your own Redis, Build Multiple Pings. ). For multiple pings, my solution is only returning single pong.
I’ve tried below piece of code.
1. Read other solutions and tried those but same issues is reoccuring.
2. parsing input using java BufferedReader and for every ping encountered I am
outputting pong using java's print writer.
Here are my logs:
❯ echo “PING\nPING” | redis-cli
PONG
(3.51s)
And here’s a snippet of my code:
BufferedReader bf = new BufferedReader(new InputStreamReader(clientSocket.getInputStream(), StandardCharsets.UTF_8));
while(bf.ready()) {
String s = bf.readLine();
if (s.equalsIgnoreCase("ping")) {
printWriter.write(HttpResponse.getPong);
}
}