Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

40
LINES

< > BotCompany Repo | #1001072 // Answer questions on port 5000

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (226L/2K/8K).

!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";
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1001072
Snippet name: Answer questions on port 5000
Eternal ID of this version: #1001072/1
Text MD5: 1a8ad3a1229a934b28ab1104d2fb6843
Transpilation MD5: 9bd8c65de8bd2fc45cb613acdfacb715
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-09-20 05:11:37
Source code size: 930 bytes / 40 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 683 / 674
Referenced in: [show references]