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

54
LINES

< > BotCompany Repo | #1006041 // Information Gatherer (collects visible peers with IP and computer ID)

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

Libraryless. Click here for Pure Java version (6972L/48K/157K).

1  
!752
2  
3  
static double sleepTime = 10; // seconds
4  
5  
!include #1006054 // ContactInvisibles
6  
7  
concepts.
8  
9  
concept IP {
10  
  S ip;
11  
  bool myIP, aware;
12  
  long lastCheck, lastSeenAware;
13  
  S computerID;
14  
  new Set<S> pastComputerIDs;
15  
}
16  
17  
static L<S> myIPs;
18  
static ContactInvisibles contactInvisibles;
19  
20  
p {
21  
  contactInvisibles = new ContactInvisibles;
22  
  myIPs = getMyIPs();
23  
  startAwareness();
24  
  conceptsAndBot();
25  
  
26  
  while licensed {
27  
    pcall {
28  
      for (S ip : getPeersListFrom("localhost"))
29  
        checkIP(ip);
30  
      contactInvisibles.doIt();
31  
    }
32  
    sleepSeconds(sleepTime);
33  
  }
34  
}
35  
36  
svoid checkIP(S ipAddress) {
37  
  if (isLoopbackIP(ipAddress)) ret;
38  
  IP ip = uniq(IP, ip := ipAddress);
39  
  cset(ip, myIP := myIPs.contains(ipAddress));
40  
  long time = now();
41  
  if (isAware(ipAddress))
42  
    cset(ip, aware := true, lastSeenAware := time);
43  
  else
44  
    cset(ip, aware := false);
45  
  cset(ip, lastCheck := time);
46  
  if (ip.aware) try {
47  
    cset(ip, computerID := matchOK(sendToAwareness(ip.ip, "get computer id")));
48  
    ip.pastComputerIDs.add(ip.computerID);
49  
  } catch e {
50  
    printShortException(e);
51  
    cset(ip, computerID := null);
52  
  }
53  
  printConcept(ip);
54  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1006041
Snippet name: Information Gatherer (collects visible peers with IP and computer ID)
Eternal ID of this version: #1006041/1
Text MD5: 108f2e890b2e950350c94ee82e584cbf
Transpilation MD5: 4a86a6ae5b9eab02b81a1c7df1cbb8b8
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-12-18 02:41:57
Source code size: 1190 bytes / 54 lines
Pitched / IR pitched: No / No
Views / Downloads: 641 / 1094
Referenced in: [show references]