Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

34
LINES

< > BotCompany Repo | #1002433 // Mini-Chat Server

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (1530L/10K/34K).

!752

static PersistentLog<McMsg> msgs;

static class McMsg {
  S miniChat, user, text;
  long when;
}

static new MultiMap<S, McMsg> byMiniChat;

p {
  msgs = new PersistentLog("msgs.log");
  for (McMsg m : msgs) byMiniChat.put(m.miniChat, m);
}

synchronized answer {
  if (match("mini chat size", s) || match("minichat size", s))
    ret n(l(msgs), "msg") + ", " + n(l(byMiniChat.keySet()), "mini-chat");
}

static synchronized void addToMiniChat(S miniChat, S user, S text) {
  new McMsg m;
  m.miniChat = miniChat;
  m.user = user;
  m.text = text;
  m.when = now();
  byMiniChat.put(m.miniChat, m);
  msgs.add(m);
}

static synchronized L<McMsg> listMiniChat(S miniChat) {
  ret cloneList(byMiniChat.get(miniChat));
}

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: #1002433
Snippet name: Mini-Chat Server
Eternal ID of this version: #1002433/1
Text MD5: fe02ac0c41ef6af8d477091f97bc59ed
Transpilation MD5: 04bf9bb65fd39f3f41bf314ddcf12e3f
Author: stefan
Category: eleu
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-01-21 23:46:40
Source code size: 756 bytes / 34 lines
Pitched / IR pitched: No / No
Views / Downloads: 616 / 1582
Referenced in: [show references]