Beispiel #1
0
    private void expireLoop() {
      while (enabled) {
        // Sleep
        try {
          synchronized (sleepLock) {
            sleepLock.wait(POLL_INTERVAL);
          }
        } catch (InterruptedException e) {
          Thread.currentThread().interrupt();
        }

        if (!enabled) break;

        // Loop over conferences
        for (JitsiMeetConference conference :
            new ArrayList<JitsiMeetConference>(conferences.values())) {
          long idleStamp = conference.getIdleTimestamp();
          // Is active ?
          if (idleStamp == -1) {
            continue;
          }
          if (System.currentTimeMillis() - idleStamp > timeout) {
            logger.info("Focus idle timeout for " + conference.getRoomName());

            conference.stop();
          }
        }
      }
    }
Beispiel #2
0
    void stop() {
      if (timeoutThread == null) {
        return;
      }

      enabled = false;

      synchronized (sleepLock) {
        sleepLock.notifyAll();
      }

      try {
        if (Thread.currentThread() != timeoutThread) {
          timeoutThread.join();
        }
        timeoutThread = null;
      } catch (InterruptedException e) {
        throw new RuntimeException(e);
      }
    }
  /**
   * Implements {@link PacketListener}. Notifies this instance that a specific {@link Packet} (which
   * this instance has already expressed interest into by returning <tt>true</tt> from {@link
   * #accept(Packet)}) has been received.
   *
   * @param packet the <tt>Packet</tt> which has been received and which this instance is given a
   *     chance to process
   */
  public void processPacket(Packet packet) {
    /*
     * As we do elsewhere, acknowledge the receipt of the Packet first and
     * then go about our business with it.
     */
    IQ iq = (IQ) packet;

    if (iq.getType() == IQ.Type.SET)
      protocolProvider.getConnection().sendPacket(IQ.createResultIQ(iq));

    /*
     * Now that the acknowledging is out of the way, do go about our
     * business with the Packet.
     */
    ColibriConferenceIQ conferenceIQ = (ColibriConferenceIQ) iq;
    boolean interrupted = false;

    try {
      processColibriConferenceIQ(conferenceIQ);
    } catch (Throwable t) {
      logger.error(
          "An error occurred during the processing of a " + packet.getClass().getName() + " packet",
          t);

      if (t instanceof InterruptedException) {
        /*
         * We cleared the interrupted state of the current Thread by
         * catching the InterruptedException. However, we do not really
         * care whether the current Thread has been interrupted - we
         * caught the InterruptedException because we want to swallow
         * any Throwable. Consequently, we should better restore the
         * interrupted state.
         */
        interrupted = true;
      } else if (t instanceof ThreadDeath) throw (ThreadDeath) t;
    }
    if (interrupted) Thread.currentThread().interrupt();
  }