!7 sclass OSChat extends DynPrintLog { S msg; bool sign; transient StefansOS_ConnectToServer connector; visualize { ret centerAndSouthWithMargins( super.visualize(), centerAndEastWithMargin(withLabel("Talk to everyone:", onEnter(jLiveValueTextField_bothWays(dm_fieldLiveValue('msg)), rThread sendMsg)), centerAndEastWithMargin(jLiveValueCheckBox("Sign", dm_fieldLiveValue('sign)), jbutton("Send", rThread sendMsg)))); } void sendMsg { S msg = trim(this.msg); if (nempty(msg)) { if (sign) msg = signWithComputerIDAndDate(msg); logQuotedWithDate(javaxDataDir("OS Chat/sent.log"), msg); print("Sending to chat: " + msg); connector.sendLine("chat: " + quote(msg)); } } void cleanMeUp { cleanUp(connector); } start { connector = new StefansOS_ConnectToServer; connector.onLine = voidfunc(S line) { new Matches m; if (startsWith(line, "chat:", m)) { S msg = unquote(m.rest()); printWithIndent("<< ", msg); logQuotedWithDate(stefansOS_chat_receivedLogFile(), msg); } }; connector.startWithSubs("chat"); } }