コード例 #1
0
ファイル: RESTReservations.java プロジェクト: mksh/jicofo
    @Override
    public void run() {
      synchronized (RESTReservations.this) {
        Iterator<Conference> conferenceIterator = conferenceMap.values().iterator();

        while (conferenceIterator.hasNext()) {
          Conference conference = conferenceIterator.next();
          Date startTimeDate = conference.getStartTime();
          if (startTimeDate == null) {
            logger.error("No 'start_time' for conference: " + conference.getName());
            continue;
          }
          long startTime = startTimeDate.getTime();
          long duration = conference.getDuration();
          // Convert duration to millis
          duration = duration * 1000L;
          long now = System.currentTimeMillis();
          if (now - startTime > duration - EXPIRE_INTERVAL) {
            // Destroy the conference
            String mucRoomName = conference.getMucRoomName();

            deleteConference(conference.getId());

            conferenceIterator.remove();

            focusManager.destroyConference(mucRoomName, "Scheduled conference duration exceeded.");
          }
        }
      }
    }
コード例 #2
0
ファイル: ApiHandler.java プロジェクト: mksh/jicofo
  /**
   * Parses JSON string returned in HTTP response and converts it to <tt>Conference</tt> instance.
   *
   * @param conference <tt>Conference</tt> instance that contains the data returned by API endpoint.
   * @param response HTTP response returned by the API endpoint.
   * @return <tt>Conference</tt> instance that contains the data returned by API endpoint.
   * @throws IOException if any IO problems occur.
   * @throws ParseException if any problems with JSON parsing occur.
   */
  private Conference readConferenceResponse(Conference conference, HttpResponse response)
      throws IOException, ParseException {
    BufferedReader rd =
        new BufferedReader(new InputStreamReader(response.getEntity().getContent()));

    if (conference != null) {
      conferenceJson.setForUpdate(conference);
    }

    jsonParser.parse(rd, conferenceJson);

    if (conference == null) {
      conference = conferenceJson.getResult();
    }

    logger.info("ID: " + conference.getId());
    logger.info("PIN: " + conference.getPin());
    logger.info("URL: " + conference.getUrl());
    logger.info("SIP ID: " + conference.getSipId());
    logger.info("START TIME: " + conference.getStartTime());
    logger.info("DURATION: " + conference.getDuration());

    return conference;
  }