Example #1
0
  /**
   * acceptClient()
   *
   * <p>Now the client can send a question and PM should responds it immediately
   *
   * <p>return: false --> close the s boolean batch = PM_Configuration.getInstance().getBatch();
   * erverSocket due no accept messages from a client (i.e. terminate)
   */
  private boolean acceptClient(BufferedReader in, BufferedWriter out) {
    try {
      String line = in.readLine();
      if (line == null) {
        System.out.println("ERROR: acceptClient. line = null");
        return false;
      }

      if (line.indexOf("terminate") != -1) {
        System.out.println("Client terminate");
        sendMessage(out, "terminate received");
        stop = true;
        return false;
      }

      if (line.indexOf("status") != -1) {
        //				System.out.println(line);
        if (readyForUse) {
          sendMessage(out, "up");
        } else {
          sendMessage(out, "loading");
        }
        return true;
      }

      if (line.indexOf("mode") != -1) {
        //				System.out.println(line);

        boolean batch = PM_Configuration.getInstance().getBatch();

        if (batch) {
          sendMessage(out, "batch");
        } else {
          sendMessage(out, "gui");
        }
        return true;
      }

      if (!readyForUse) {
        sendMessage(out, "loading");
        return true;
      }
      sendMessage(out, getMessage(line));
    } catch (IOException ex) {
      System.out.println("ex: " + ex);
      ex.printStackTrace();
      return false;
    }

    return true;
  }
Example #2
0
 /**
  * initConfigDone()
  *
  * <p>The configfiles init is done. You can get now the TLPD.
  */
 public synchronized void initConfigDone() {
   albumName = PM_Configuration.getInstance().getAlbumName();
   topLevelPictureDirectory = PM_Configuration.getInstance().getTopLevelPictureDirectory();
 }