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

38
LINES

< > BotCompany Repo | #1000962 // suckFromChat / suckFromChatNoHistory

JavaX fragment (include)

1  
static int suckFromChat_chatPort = 9751;
2  
static Socket suckFromChat_socket;
3  
static BufferedReader suckFromChat_in, suckFromChatNoHistory_in;
4  
static boolean suckFromChat_present;
5  
6  
static S suckFromChatNoHistory() ctex {
7  
  if (suckFromChatNoHistory_in == null) {
8  
    startChatServerIfNotUp();
9  
    waitForChatServer();
10  
    final Socket s = new Socket("localhost", suckFromChat_chatPort+2);
11  
    print("connected to chat");
12  
    suckFromChatNoHistory_in = new BufferedReader(
13  
      new InputStreamReader(s.getInputStream(), "UTF-8"));
14  
  }
15  
  return suckFromChatNoHistory_in.readLine();
16  
}
17  
18  
static S suckFromChat() ctex {
19  
  if (suckFromChat_in == null) {
20  
    startChatServerIfNotUp();
21  
    waitForChatServer();
22  
    suckFromChat_socket = new Socket("localhost", suckFromChat_chatPort+1);
23  
    print("connected to chat");
24  
    //reportToChat("Hey ho I'm sucking!");
25  
    suckFromChat_in = new BufferedReader(
26  
      new InputStreamReader(suckFromChat_socket.getInputStream(), "UTF-8"));
27  
  }
28  
  S line = suckFromChat_in.readLine();
29  
  if (line != null && line.length() == 0) suckFromChat_present = true; // We have reached the present :)
30  
  return line;
31  
}
32  
33  
static void suckFromChat_close() ctex {
34  
  if (suckFromChat_socket != null) {
35  
    suckFromChat_socket.close();
36  
    suckFromChat_socket = null;
37  
  }
38  
}

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: #1000962
Snippet name: suckFromChat / suckFromChatNoHistory
Eternal ID of this version: #1000962/1
Text MD5: 5e7a7fa872824abb2306f27ff9b0e4e0
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-09-24 17:40:28
Source code size: 1321 bytes / 38 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 760 / 973
Referenced in: [show references]