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).

!7

cmodule MachineGroupChat > DynPrintLog {
  S msg;
  bool sign;
  transient StefansOS_ConnectToServer connector;
  
  visualize {
    JComponent log = super.visualize();
    enableWordWrap();
    ret centerAndSouthWithMargins(log,
      centerAndEastWithMargin(withLabel("Talk to everyone:", onEnterAndCtrlEnter(jLiveValueTextField_bothWays(dm_fieldLiveValue('msg)), rThread sendMsg)),
        centerAndEastWithMargin(jLiveValueCheckBox("Sign", dm_fieldLiveValue('sign)), jbutton("Send", rThread sendMsg))));
  }
  
  void sendMsg {
    postMsg(trim(msg), sign);
    setField(msg := "");
  }
  
  void postSigned(S msg) q { postMsg(msg, true); }
  void postMsg(S _msg, bool sign) q {
    S msg = _msg;
    if (empty(msg = trim(msg))) ret;
    if (sign) msg = signWithComputerIDAndDate(msg);
    vmBus_send('sendingToMachineChat, msg);
    //logQuotedWithDate(javaxDataDir("OS Chat/sent.log"), msg);
    //print("Sending to machine chat: " + msg);
    connector.sendLine("machineChat: " + quote(msg));
  }
  
  void cleanMeUp { cleanUp(connector); }
  
  start {
    thread { exportComputerPublicKeyToServerMechList(); }
    connector = new StefansOS_ConnectToServer;
    connector.onLine = voidfunc(S line) {
      new Matches m;
      if (startsWith(line, "machineChat:", m)) {
        S msg = unquote(m.rest());
        //infoBox(indent(">> ", msg));
        vmBus_send('gotFromMachineChat, msg);
        //logQuotedWithDate(stefansOS_chat_receivedLogFile(), msg);
      }
    };
    connector.startWithSubs("machineChat");
  }
}

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: 162 / 168441
Version history: 4 change(s)
Referenced in: [show references]