!7 cmodule OSChat > 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('sendingToChat, msg); logQuotedWithDate(javaxDataDir("OS Chat/sent.log"), msg); //print("Sending to chat: " + msg); connector.sendLine("chat: " + quote(msg)); } void cleanMeUp { cleanUp(connector); } start { thread { exportComputerPublicKeyToServerMechList(); } connector = new StefansOS_ConnectToServer; connector.onLine = voidfunc(S line) { new Matches m; if (startsWith(line, "chat:", m)) { S msg = unquote(m.rest()); infoBox(indent(">> ", msg)); vmBus_send('gotFromChat, msg); logQuotedWithDate(stefansOS_chat_receivedLogFile(), msg); } }; connector.startWithSubs("chat"); } }