Ejemplo n.º 1
0
  void turnOnChatLog() throws IOException {
    Global.log("Connecting to chat log...");
    while (true) {
      if (isDisposed()) throw new IOException("Client game disposed");
      Global.log("Connecting to port " + Global.chatLogPort() + "...");
      try {
        chatLog = new ClientByteStream(ip, Global.chatLogPort(), 1);
        break;
      } catch (IOException ex) {
      }
    }
    Global.log("Connected!");
    timers.add(
        new FixedTimer(
            new FixedTask() {
              public boolean fixedRate() {
                return false;
              }

              public float FPS() {
                return Global.ReceiveFPS;
              }

              public void run() {
                String s = null;
                try {
                  s = chatLog.readLine();
                } catch (IOException ex) {
                  System.err.println("Error reading from chat log: " + ex);
                  Global.onException();
                  stop();
                  return;
                }
                if (s == null) return;
                log(s);
              }
            }));
  }