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

33
LINES

< > BotCompany Repo | #1001317 // Dependent VM

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

Libraryless. Click here for Pure Java version (359L/3K/10K).

!747

m {
  static int masterPort;
  static DialogIO masterConn;
  static int interval = 1000;
  
  p {
    masterPort = parseInt(args[0]);
    masterConn = talkTo("localhost", masterPort);
    print("Dependent VM: Connected to master at port " + masterPort + ".");
    masterConn.readLine();
    masterConn.sendLine("Master: My VM port is " + myVMPort());
    masterConn.readLine();
    while (shouldStayAlive())
      sleep(interval);
    System.exit(0);
  }
  
  static boolean shouldStayAlive() {
    try {
      masterConn.sendLine("Master: Should I stay alive?");
      S answer = masterConn.readLine();
      boolean yes = match3("yes", answer) || match3("yes ...", answer);
      if (!yes)
        print("Master said: " + answer);
      return yes;
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }
  }
}

Author comment

Began life as a copy of #1001316

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1001317
Snippet name: Dependent VM
Eternal ID of this version: #1001317/1
Text MD5: 63d1447179c9e12f07830e859ac5ffed
Transpilation MD5: fbdea653b4860aa6b7933f50d71dba2d
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-10-09 18:22:48
Source code size: 875 bytes / 33 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 495 / 913
Referenced in: [show references]