Libraryless. Click here for Pure Java version (226L/2K/8K).
1 | !747 |
2 | !1000868 // dialogHandler { |
3 | |
4 | m { |
5 | static new L<S> questions; |
6 | static int port = 5000; |
7 | |
8 | !include #1001065 // Dialog classes |
9 | |
10 | p { |
11 | startDialogServer(port, dialogHandler { |
12 | String dialogID = randomID(8); |
13 | |
14 | io.sendLine("Your ID: " + dialogID); |
15 | |
16 | while (io.isStillConnected()) { |
17 | if (io.waitForLine()) { |
18 | String line = io.readLineNoBlock(); |
19 | S s = dialogID + " at " + now() + ": " + quote(line); |
20 | print(s); |
21 | if (line == "bye") { |
22 | io.sendLine("bye stranger"); |
23 | return; |
24 | } |
25 | questions.add(s); |
26 | S answer = getAnswer(line); |
27 | print("! " + answer); |
28 | io.sendLine(answer == null ? "null" : answer); |
29 | //appendToLog(logFile, s); |
30 | } |
31 | } |
32 | }); |
33 | |
34 | sleep(); |
35 | } |
36 | |
37 | static S getAnswer(S question) { |
38 | return "whatever"; |
39 | } |
40 | } |
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1001072 |
Snippet name: | Answer questions on port 5000 |
Eternal ID of this version: | #1001072/1 |
Text MD5: | 1a8ad3a1229a934b28ab1104d2fb6843 |
Transpilation MD5: | 9bd8c65de8bd2fc45cb613acdfacb715 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-09-20 05:11:37 |
Source code size: | 930 bytes / 40 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 685 / 677 |
Referenced in: | [show references] |