static new Map<S, Integer> getBotPort_cache;
static int getBotPort_timeout = 5000;
// returns 0 if not found
static int getBotPort(S searchPattern) {
Integer port = getBotPort_cache.get(searchPattern);
if (port != null) try {
DialogIO io = talkTo("localhost", port);
io.waitForLine(/*getBotPort_timeout*/); // TODO: implement
S line = io.readLineNoBlock();
if (indexOfIgnoreCase(line, searchPattern) == 0) {
io.close();
return port;
}
} catch (Exception e) {
e.printStackTrace();
}
for (ProgramScan.Program p : quickBotScan())
if (indexOfIgnoreCase(p.helloString, searchPattern) == 0) { // strict matching - start of hello string only, but case-insensitive
getBotPort_cache.put(searchPattern, p.port);
return p.port;
}
return 0;
}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: | 1149 / 1364 |
| Referenced in: | [show references] |