public void listenCommands() {
    try {
      while (true) {
        String line = reader.readLine();
        if (line.equals("x")) {
          this.server.shutdown();
          logger.info("Goodbye");

          System.exit(13);
        } else if (line.equals("reset")) {
          jedis.del("users");
          jedis
              .smembers("servers")
              .forEach(
                  server -> {
                    jedis.hset(server, "conns", "0");
                    jedis.hset(server, "throughput", "0");
                  });

          jedis
              .smembers("rooms")
              .forEach(
                  room -> {
                    jedis.del(room);
                  });

        } else if (line.equals("stats")) {
          String jedisStats = "\n::: JEDIS STATS ::: " + "\n";

          jedisStats += JedisFactory.getJedisStats() + "\n";

          String serverStats = "\n::: SERVERS STATS :::" + "\n";
          serverStats += "Number of WS servers: " + jedis.smembers("servers").size() + "\n";
          Set<String> servers = jedis.smembers("servers");
          Iterator<String> iter = servers.iterator();
          while (iter.hasNext()) {
            String server = iter.next();
            serverStats +=
                server
                    + ": "
                    + "port: "
                    + jedis.hget(server, "port")
                    + " online: "
                    + jedis.hget(server, "online")
                    + " conns: "
                    + jedis.hget(server, "conns")
                    + " throughput: "
                    + jedis.hget(server, "throughput")
                    + "\n";
          }

          String userRoomStats = "\n::: USER & ROOMS STATS :::" + "\n";
          userRoomStats += "Total users: " + jedis.smembers("users").size() + "\n";
          userRoomStats += "Total rooms: " + jedis.smembers("rooms").size() + "\n";
          Set<String> rooms = jedis.smembers("rooms");
          Iterator<String> iter2 = rooms.iterator();
          while (iter2.hasNext()) {
            String room = iter2.next();
            userRoomStats +=
                room
                    + ": "
                    + "number of users: "
                    + jedis.smembers(room).size()
                    + " users: "
                    + jedis.smembers(room)
                    + "\n";
          }

          logger.info(jedisStats + serverStats + userRoomStats);
        }
      }

    } catch (IOException e) {
      logger.error("Error while reading commands ", e);
    } finally {
      this.jedis.close();
    }
  }
 public HTTPServer() {
   this.reader = new BufferedReader(new InputStreamReader(System.in));
   server = HttpServer.createSimpleServer("localhost", 8001);
   jedis = JedisFactory.getJedis();
 }