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

48
LINES

< > BotCompany Repo | #1025927 // Machine Group Chat [Public chat among Stefan's OS machines]

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

Uses 911K of libraries. Click here for Pure Java version (10237L/52K).

1  
!7
2  
3  
cmodule MachineGroupChat > DynPrintLog {
4  
  S msg;
5  
  bool sign;
6  
  transient StefansOS_ConnectToServer connector;
7  
  
8  
  visualize {
9  
    JComponent log = super.visualize();
10  
    enableWordWrap();
11  
    ret centerAndSouthWithMargins(log,
12  
      centerAndEastWithMargin(withLabel("Talk to everyone:", onEnterAndCtrlEnter(jLiveValueTextField_bothWays(dm_fieldLiveValue('msg)), rThread sendMsg)),
13  
        centerAndEastWithMargin(jLiveValueCheckBox("Sign", dm_fieldLiveValue('sign)), jbutton("Send", rThread sendMsg))));
14  
  }
15  
  
16  
  void sendMsg {
17  
    postMsg(trim(msg), sign);
18  
    setField(msg := "");
19  
  }
20  
  
21  
  void postSigned(S msg) q { postMsg(msg, true); }
22  
  void postMsg(S _msg, bool sign) q {
23  
    S msg = _msg;
24  
    if (empty(msg = trim(msg))) ret;
25  
    if (sign) msg = signWithComputerIDAndDate(msg);
26  
    vmBus_send('sendingToMachineChat, msg);
27  
    //logQuotedWithDate(javaxDataDir("OS Chat/sent.log"), msg);
28  
    //print("Sending to machine chat: " + msg);
29  
    connector.sendLine("machineChat: " + quote(msg));
30  
  }
31  
  
32  
  void cleanMeUp { cleanUp(connector); }
33  
  
34  
  start {
35  
    thread { exportComputerPublicKeyToServerMechList(); }
36  
    connector = new StefansOS_ConnectToServer;
37  
    connector.onLine = voidfunc(S line) {
38  
      new Matches m;
39  
      if (startsWith(line, "machineChat:", m)) {
40  
        S msg = unquote(m.rest());
41  
        //infoBox(indent(">> ", msg));
42  
        vmBus_send('gotFromMachineChat, msg);
43  
        //logQuotedWithDate(stefansOS_chat_receivedLogFile(), msg);
44  
      }
45  
    };
46  
    connector.startWithSubs("machineChat");
47  
  }
48  
}

Author comment

Began life as a copy of #1017119

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1025927
Snippet name: Machine Group Chat [Public chat among Stefan's OS machines]
Eternal ID of this version: #1025927/5
Text MD5: e62fa7ce266f151aef54713e40bf16b8
Transpilation MD5: 1a1abbb0583a2973ecb7b2981887ef84
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: 2019-10-30 15:42:00
Source code size: 1581 bytes / 48 lines
Pitched / IR pitched: No / No
Views / Downloads: 239 / 169429
Version history: 4 change(s)
Referenced in: [show references]