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

38
LINES

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

JavaX fragment (include)

static int suckFromChat_chatPort = 9751;
static Socket suckFromChat_socket;
static BufferedReader suckFromChat_in, suckFromChatNoHistory_in;
static boolean suckFromChat_present;

static S suckFromChatNoHistory() ctex {
  if (suckFromChatNoHistory_in == null) {
    startChatServerIfNotUp();
    waitForChatServer();
    final Socket s = new Socket("localhost", suckFromChat_chatPort+2);
    print("connected to chat");
    suckFromChatNoHistory_in = new BufferedReader(
      new InputStreamReader(s.getInputStream(), "UTF-8"));
  }
  return suckFromChatNoHistory_in.readLine();
}

static S suckFromChat() ctex {
  if (suckFromChat_in == null) {
    startChatServerIfNotUp();
    waitForChatServer();
    suckFromChat_socket = new Socket("localhost", suckFromChat_chatPort+1);
    print("connected to chat");
    //reportToChat("Hey ho I'm sucking!");
    suckFromChat_in = new BufferedReader(
      new InputStreamReader(suckFromChat_socket.getInputStream(), "UTF-8"));
  }
  S line = suckFromChat_in.readLine();
  if (line != null && line.length() == 0) suckFromChat_present = true; // We have reached the present :)
  return line;
}

static void suckFromChat_close() ctex {
  if (suckFromChat_socket != null) {
    suckFromChat_socket.close();
    suckFromChat_socket = null;
  }
}

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: 758 / 970
Referenced in: [show references]