Exemplo n.º 1
0
 public String Tclient(int num) throws SocketException, IOException, InterruptedException {
   TelnetService TC = TNH.get(num);
   TNH.get(num).mynum = num;
   TNH.get(num).myname = props("server" + num + "name");
   String rtn = TC.getTelnetSessionAsString(Integer.toString(num));
   if (rtn.equals("reload")) {
     return rtn;
   }
   TC.readit(" ", "Room error");
   dw.append("Server " + num + ": ");
   TC.write("gos " + entrymsg);
   TC.readit("\n", "Room error");
   TC.write("\n");
   String msg = null;
   TC.whoCheck = true;
   while (TC.loggedin == 1) {
     TC.readUntil("gossips:");
     msg = TC.readUntil("\n");
     if (msg != null) {
       if (msg.equals("!OffLINE+02")) {
       } else if (msg.contains("users in the game.")) {
       } else {
         sayit(num, msg);
       }
     }
   }
   dw.append("Server " + num + " is offline.");
   killme(num);
   return "reload";
 }
Exemplo n.º 2
0
 @Override
 public void run() {
   while (!SH.get(tcn).isInterrupted()) {
     try {
       String rtn = Tclient(tcn);
       if (rtn.equals("reload")) {
         TNH.get(tcn).loggedin = 0;
         SH.get(tcn).interrupt();
         TNH.get(tcn).killme();
       }
     } catch (SocketException e) {
       dw.append("Server " + tcn + " offline.");
       TNH.get(tcn).loggedin = 0;
       SH.get(tcn).interrupt();
     } catch (IOException | InterruptedException e) {
       e.printStackTrace();
       dw.append("Server" + tcn + ": Bad Server Address");
       SH.get(tcn).interrupt();
     }
   }
   SH.remove(tcn);
 }