!747
!1000868 // dialogHandler {

m {
  static new L<S> questions;
  static int port = 5000;
  
  !include #1001065 // Dialog classes
  
  p {
    startDialogServer(port, dialogHandler {
      String dialogID = randomID(8);
      
      io.sendLine("Your ID: " + dialogID);
      
      while (io.isStillConnected()) {
        if (io.waitForLine()) {
          String line = io.readLineNoBlock();
          S s = dialogID + " at " + now() + ": " + quote(line);
          print(s);
          if (line == "bye") {
            io.sendLine("bye stranger");
            return;
          }
          questions.add(s);
          S answer = getAnswer(line);
          print("! " + answer);
          io.sendLine(answer == null ? "null" : answer);
          //appendToLog(logFile, s);
        }
      }
    });
    
    sleep();
  }
  
  static S getAnswer(S question) {
    return "whatever";
  }
}