Example #1
0
  /**
   * Returns a collection of all active AsteriskChannels.
   *
   * @return a collection of all active AsteriskChannels.
   */
  Collection<AsteriskChannel> getChannels() {
    Collection<AsteriskChannel> copy;

    synchronized (channels) {
      copy = new ArrayList<AsteriskChannel>(channels.size() + 2);
      for (AsteriskChannel channel : channels) {
        if (channel.getState() != ChannelState.HUNGUP) {
          copy.add(channel);
        }
      }
    }
    return copy;
  }
Example #2
0
  /** Removes channels that have been hung more than {@link #REMOVAL_THRESHOLD} milliseconds. */
  private void removeOldChannels() {
    Iterator<AsteriskChannelImpl> i;

    synchronized (channels) {
      i = channels.iterator();
      while (i.hasNext()) {
        final AsteriskChannel channel = i.next();
        final Date dateOfRemoval = channel.getDateOfRemoval();
        if (channel.getState() == ChannelState.HUNGUP && dateOfRemoval != null) {
          final long diff = DateUtil.getDate().getTime() - dateOfRemoval.getTime();
          if (diff >= REMOVAL_THRESHOLD) {
            i.remove();
          }
        }
      }
    }
  }
Example #3
0
 void disconnected() {
   synchronized (channels) {
     channels.clear();
   }
 }
Example #4
0
 private void addChannel(AsteriskChannelImpl channel) {
   synchronized (channels) {
     channels.add(channel);
   }
 }