示例#1
0
  @Override
  public void run() {
    try {
      Messenger.sendEvent(MT.TIMER_SERVICE_CONNECTION, true);

      while (!done) {
        String line = in.readLine();
        log.info("TimerClient reads: " + line);
        if (line.startsWith("DIAL ")) {
          LeftRightDialin d = new LeftRightDialin();
          d.decode(line.substring(5));
          Messenger.sendEvent(MT.TIMER_SERVICE_DIALIN, d);
        } else if (line.startsWith("RUN ")) {
          Run r = new Run();
          r.decode(line.substring(4));
          Messenger.sendEvent(MT.TIMER_SERVICE_RUN, r);
        } else if (line.startsWith("DELETE ")) {
          Run r = new Run();
          r.decode(line.substring(7));
          Messenger.sendEvent(MT.TIMER_SERVICE_DELETE, r);
        }
      }
    } catch (IOException ex) {
      log.log(Level.INFO, "read failure: " + ex, ex);
    }

    try {
      sock.close();
    } catch (IOException ioe) {
    }
    Messenger.sendEvent(MT.TIMER_SERVICE_CONNECTION, false);
  }
示例#2
0
 public boolean sendDial(LeftRightDialin d) {
   return send(("DIAL " + d.encode() + "\n"));
 }