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

61
LINES

< > BotCompany Repo | #1016578 // All Online Computers [Show Connected Computers]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 1113K of libraries. Click here for Pure Java version (14600L/76K).

!7

cm AllOnlineComputers > DynCalculatedList {
  transient LS computerIDs, data;
  transient StefansOS_ConnectToServer connector;
  transient JLabel trayIcon;
  
  LS calc() { ret data; }
  
  start {
    dm_addTrayIcon(trayIcon = jlabel());
    updateList();
    ownResource(connector = new StefansOS_ConnectToServer);
    connector.onLine = voidfunc(S line) {
      new Matches m;
      if (swic(line, "ComputerIDs = ", m)) {
        computerIDs = (LS) safeUnstruct($1);
        updateList();
        vmBus_send('onlineComputerIDs, computerIDs);
        setModuleName(n2(computerIDs, "Online Computer"));
      }
    };
    connector.startWithSubs("computerIDs");
  }
  
  afterVisualize {
    listPopupMenuItemsThreaded(list, "Send clipboard there", rEnter {
      pcall-infobox {
        dm_sendClipboardTo_verbose(selectedComputerID());
      }
    }, "Set name...", rEnter { setNameDialog(selectedComputerID()) });
  }
  
  // API
  
  LS onlineComputerIDs() { ret computerIDs; }
  
  bool isComputerOnline(S computerID) {
    ret contains(computerIDs, computerID);
  }

  void updateList {
    O computerNames = dm_computerNames_opt();
    if (setField(data := sortedIC(map(computerIDs, func(S id) -> S {
      S name = dm_callOpt(computerNames, "nameForID", id);
      ret (eq(id, computerID()) ? "[this one] " : "")
        + (nempty(name) ? name + " (" + id + ")" : id);
    }))));
      dm_q(r update);

    setTextAndToolTip(trayIcon, n2(data) + "c", nComputers(data) + " online");
  }

  S selectedComputerID() {
    ret extractLastComputerID(selected());
  }

  void setNameDialog(S computerID) {
    dm_call(dm_requireComputerNames(), 'openDialogForComputerID, computerID);
  }
}

Author comment

Began life as a copy of #1016576

download  show line numbers  debug dex  old transpilations   

Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, hpgrupgrauku, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1016578
Snippet name: All Online Computers [Show Connected Computers]
Eternal ID of this version: #1016578/43
Text MD5: 9df1357f3bbe9ac0b6582d3660202ea8
Transpilation MD5: 6eafaf66f045ccc24c774294eba0b7f0
Author: stefan
Category: javax / stefan's os
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-10 16:21:53
Source code size: 1755 bytes / 61 lines
Pitched / IR pitched: No / No
Views / Downloads: 568 / 83387
Version history: 42 change(s)
Referenced in: #1016875 - StefansOS_ConnectToServer
#1017119 - OS Chat [Public Chat among Stefan's OS users]
#1019281 - Computer Names [give names to computers, Dyn Module]
#1019753 - All Online Computers [Show Connected Computers, old version]
#1019894 - Mini VNC [Dyn Module, control other computer's mouse & keyboard]
#1020212 - Stack Trace showing unnoticed deadlock in old version of setField()
#1020215 - Multi-Line Java Eval On Other Machine [Execute Java Code Remotely]
#1020800 - dm_requireOnlineComputersModule