Uses 911K of libraries. Click here for Pure Java version (14117L/78K).
1 | !7 |
2 | |
3 | cmodule OSChat > 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('sendingToChat, msg); |
27 | logQuotedWithDate(javaxDataDir("OS Chat/sent.log"), msg); |
28 | //print("Sending to chat: " + msg); |
29 | connector.sendLine("chat: " + 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, "chat:", m)) { |
40 | S msg = unquote(m.rest()); |
41 | infoBox(indent(">> ", msg)); |
42 | vmBus_send('gotFromChat, msg); |
43 | logQuotedWithDate(stefansOS_chat_receivedLogFile(), msg); |
44 | } |
45 | }; |
46 | connector.startWithSubs("chat"); |
47 | } |
48 | } |
Began life as a copy of #1016578
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, hpgrupgrauku, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1017119 |
Snippet name: | OS Chat [Public Chat among Stefan's OS users] |
Eternal ID of this version: | #1017119/29 |
Text MD5: | 7c04b439e4940ae88f33affa00042e67 |
Transpilation MD5: | f117f917f5f99a356941a08cf0cc0dbc |
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:30:06 |
Source code size: | 1522 bytes / 48 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 589 / 115831 |
Version history: | 28 change(s) |
Referenced in: | [show references] |