1 | static new Map<S, Integer> getBotPort_cache; |
2 | static int getBotPort_timeout = 5000; |
3 | |
4 | // returns 0 if not found |
5 | static int getBotPort(S searchPattern) { |
6 | Integer port = getBotPort_cache.get(searchPattern); |
7 | if (port != null) try { |
8 | DialogIO io = talkTo("localhost", port); |
9 | io.waitForLine(/*getBotPort_timeout*/); // TODO: implement |
10 | S line = io.readLineNoBlock(); |
11 | if (indexOfIgnoreCase(line, searchPattern) == 0) { |
12 | io.close(); |
13 | return port; |
14 | } |
15 | } catch (Exception e) { |
16 | e.printStackTrace(); |
17 | } |
18 | |
19 | for (ProgramScan.Program p : quickBotScan()) |
20 | if (indexOfIgnoreCase(p.helloString, searchPattern) == 0) { // strict matching - start of hello string only, but case-insensitive |
21 | getBotPort_cache.put(searchPattern, p.port); |
22 | return p.port; |
23 | } |
24 | |
25 | return 0; |
26 | } |
Began life as a copy of #1001303
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: | #1001422 |
Snippet name: | getBotPort |
Eternal ID of this version: | #1001422/1 |
Text MD5: | 743f185303976370ee6ce4be2cd76a65 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-10-15 19:10:11 |
Source code size: | 832 bytes / 26 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 658 / 923 |
Referenced in: | [show references] |