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

39
LINES

< > BotCompany Repo | #1001676 // addToMultiPort

JavaX fragment (include)

static Object addToMultiPort_responder;

static long addToMultiPort(final S botName) {
  ret addToMultiPort(botName, new Object() {
    public S answer(S s, L<S> history) {
      S answer = cast callOpt(getMainClass(), "answer", s, history);
      if (answer != null) ret answer;
      answer = (S) callOpt(getMainClass(), "answer", s);
      if (answer != null) ret answer;
      if (match3("get injection id", s))
        ret getInjectionID();
      ret null;
    }
  });
}

static long addToMultiPort(final S botName, final O responder) {
  //print(botName);
  addToMultiPort_responder = responder;
  startMultiPort();
  L ports = getMultiPorts();
  if (ports == null) ret 0;
  if (ports.isEmpty())
    fail("No multiports!");
  if (ports.size() > 1)
    print("Multiple multi-ports. Using last one.");
  O port = last(ports);
  O responder2 = new O() {
    public S answer(S s, L<S> history) {
      if (match3("get injection id", s))
        ret getInjectionID();
      if (match3("your name", s))
        ret botName;
      ret (S) call(responder, "answer", s, history);
    }
  };
  record(responder2);
  ret (Long) call(port, "addResponder", botName, responder2);
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1001676
Snippet name: addToMultiPort
Eternal ID of this version: #1001676/1
Text MD5: 229e21fbd4739db4c9e18351f69c5cca
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-11-10 17:38:06
Source code size: 1213 bytes / 39 lines
Pitched / IR pitched: No / No
Views / Downloads: 734 / 1929
Referenced in: [show references]