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

30
LINES

< > BotCompany Repo | #1027047 // OS Instances Connector [on port 6000 by default]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Libraryless. Click here for Pure Java version (16224L/119K).

1  
!7
2  
3  
sclass OIC > DynPrintLogAndEnabled {
4  
  switchable int port = 6000;
5  
  switchable bool verbose;
6  
  transient OSInstancesConnector connector;
7  
  
8  
  start-thread {
9  
    if (!enabled) ret;
10  
    connector = OSInstancesConnector(port);
11  
    connector.onLineReceived.add(voidfunc(S line, O socket, O state) enter {
12  
      if (verbose)
13  
        print("Line received: " + shorten(50, line));
14  
    });
15  
    connector.start();
16  
    print("Connector on port " + port + " listening");
17  
    print("IPs: " + myIPs());
18  
    dm_registerAs_direct instancesConnector();
19  
  }
20  
  
21  
  void cleanMeUp {
22  
    dispose connector;
23  
  }
24  
  
25  
  // API
26  
  
27  
  void sendToChannel(S channel, S line) {
28  
    connector.getChannel(channel).handleLine(line, null);
29  
  }
30  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027047
Snippet name: OS Instances Connector [on port 6000 by default]
Eternal ID of this version: #1027047/10
Text MD5: 05d90b75633d37819bbe78b55b982ba3
Transpilation MD5: c07335874df6428e9cf77e436945e324
Author: stefan
Category: javax / networking
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-15 15:20:36
Source code size: 744 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 388 / 5515
Version history: 9 change(s)
Referenced in: [show references]