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

39
LINES

< > BotCompany Repo | #1019610 // dm_evalOnOtherMachineWithReturnValue

JavaX fragment (include)

1  
static long dm_evalOnOtherMachineWithReturnValue_timeout = 60000;
2  
3  
sO dm_evalOnOtherMachineWithReturnValue(fS computerID, S code, O... _) {
4  
  fS id = aGlobalID();
5  
  final new Var<Either<O, S>> var;
6  
  temp vmBus_onMessage('gotFromPrivateChat, voidfunc(S sender, S msg) {
7  
    if (var.has() || neq(sender, computerID)) ret;
8  
    new Matches m;
9  
    if (!startsWith(msg, "done " + id + " ", m)) ret;
10  
    if (neq(getAuthorOfSignedText(msg), computerID)) {
11  
      File f = javaxCachesDir("failed-eval-msg-" + computerID);
12  
      saveTextFile(f, msg);
13  
      var.set((Either) eitherB("eval result from " + computerID + " did not verify, saved as " + f));
14  
    }
15  
    S s = firstLine(m.rest());
16  
    if (startsWith(s, "direct: ", m))
17  
      var.set((Either) eitherA(m.rest()));
18  
    else if (startsWith(s, "quoted: ", m))
19  
      var.set((Either) eitherA(unquote(m.rest())));
20  
    else if (startsWith(s, "base64: ", m))
21  
      var.set((Either) eitherA(base64decode(m.rest())));
22  
    else if (startsWith(s, "error: ", m))
23  
      var.set((Either) eitherB(m.rest()));
24  
    else
25  
      var.set((Either) eitherB("unknown mode"));
26  
  });
27  
  dm_privateChat_sendSigned(computerID, computerID + " eval "
28  
    + (boolOptPar(_, 'realEval) ? "real " : "")
29  
    + (boolOptPar(_, 'fresh) ? "fresh " : "")
30  
    + id + ": " + code);
31  
  Either<O, S> e = waitForVarToBeNotNullWithTimeout(var, dm_evalOnOtherMachineWithReturnValue_timeout);
32  
  
33  
  if (boolPar updateControllableFlag(_))
34  
    dm_pcall('controllableComputerList, 'setControllableByMe, computerID, eitherIsA(e));
35  
 
36  
  if (e == null) fail("timeout");
37  
  if (eitherIsB(e)) fail(eitherGetB(e));
38  
  ret eitherGetA(e);
39  
}

Author comment

Began life as a copy of #1019606

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, snaazhdonpnp, tvejysmllsmz, vouqrxazstgt, wnsclhtenguj, xrpafgyirdlv

No comments. add comment

Snippet ID: #1019610
Snippet name: dm_evalOnOtherMachineWithReturnValue
Eternal ID of this version: #1019610/28
Text MD5: 57eda72f41247f2f71ea994d58d2987d
Author: stefan
Category: javax / stefan's os
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-10 11:03:36
Source code size: 1660 bytes / 39 lines
Pitched / IR pitched: No / No
Views / Downloads: 394 / 528
Version history: 27 change(s)
Referenced in: [show references]