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

30
LINES

< > BotCompany Repo | #1005451 // newFindBot2

JavaX fragment (include)

1  
static Map<S, Int> newFindBot2_cache = synchroHashMap();
2  
sbool newFindBot2_verbose;
3  
4  
static DialogIO newFindBot2(S name) {
5  
  Int port = newFindBot2_cache.get(name);
6  
  if (port != null) {
7  
    if (newFindBot2_verbose)
8  
      print("newFindBot2: testing " + name + " => " + port);
9  
    DialogIO io = talkTo(port);
10  
    S q = format("has bot *", name);
11  
    S s = io.ask(q);
12  
    if (match("yes", s)) {
13  
      io = talkToSubBot(name, io);
14  
      call(io, "pushback", "?"); // put some hello string in (yes, this should be improved.)
15  
      ret io;
16  
    }
17  
    // bot not there anymore - remove cache entry
18  
    newFindBot2_cache.remove(name);
19  
    if (newFindBot2_verbose)
20  
      print("newFindBot2: dropping " + name + " => " + port);
21  
  }
22  
  
23  
  DialogIO io = findBot(name);
24  
  if (io != null) {
25  
    newFindBot2_cache.put(name, io.getPort());
26  
    if (newFindBot2_verbose)
27  
      print("newFindBot2: remembering " + name + " => " + port);
28  
  }
29  
  ret io;
30  
}

Author comment

Began life as a copy of #1001964

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1005451
Snippet name: newFindBot2
Eternal ID of this version: #1005451/1
Text MD5: 65f1567ebd04a178865553eb19923672
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-11-19 13:29:50
Source code size: 962 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 477 / 483
Referenced in: [show references]