1 | static class ChatLine { |
2 | int id, room; |
3 | S who, text; |
4 | boolean isBot, auth; |
5 | } |
6 | |
7 | static int suckWebChat_lastID; |
8 | static long suckWebChat_lastSuck; |
9 | static int suckWebChat_room = 1; |
10 | |
11 | static L<ChatLine> suckWebChat(S myName) { |
12 | ret suckWebChat(myName, 1); |
13 | } |
14 | |
15 | // suckFirst = how many lines to suck on startup (history) |
16 | static L<ChatLine> suckWebChat(S myName, int suckFirst) { |
17 | if (now() < suckWebChat_lastSuck + 500) |
18 | print("Warning: Sucking a lot :)"); |
19 | suckWebChat_lastSuck = now(); |
20 | int n = suckWebChat_lastID == 0 ? suckFirst : 1000; |
21 | Map data = (Map) jsonDecode(loadPageSilently("tinybrain.de:8080/tb-int/groupchat.json.lines.php?room=" + suckWebChat_room + "&fromID=" + suckWebChat_lastID + "&n=" + n |
22 | + "&who=" + urlencode(myName))); |
23 | L<Map<S, S>> lines = (L) data.get("lines"); |
24 | new L<ChatLine> list; |
25 | for (Map<S, S> m : lines) { |
26 | new ChatLine l; |
27 | l.who = m.get("who"); |
28 | l.text = m.get("text"); |
29 | l.isBot = "1".equals(m.get("bot")); |
30 | l.auth = eq(m.get("auth"), "1"); |
31 | l.id = parseInt(m.get("id")); |
32 | l.room = room; |
33 | if (l.id > suckWebChat_lastID) suckWebChat_lastID = l.id; |
34 | list.add(l); |
35 | } |
36 | ret list; |
37 | } |
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1001576 |
Snippet name: | suckWebChat |
Eternal ID of this version: | #1001576/1 |
Text MD5: | b53f34fb567822ef58f9638d656220f0 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-03-31 19:40:01 |
Source code size: | 1186 bytes / 37 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 708 / 912 |
Referenced in: | [show references] |