コード例 #1
0
ファイル: PageGroup.java プロジェクト: astubbs/sipxecs
  /**
   * Trigger a page of all the destinations.
   *
   * @param inbound The inbound Leg (audio from here goes to all destinations)
   * @param inboundRtp The destination to send RTP packets so the inbound caller can hear.
   * @param alertInfoKey The magic key needed for Polycom Auto-Answer
   * @return
   */
  public boolean page(Leg inbound, InetSocketAddress inboundRtp, String alertInfoKey) {
    if (busy == false) {
      LOG.debug("PageGroup::page starting");
      busy = true;
      this.inbound = inbound;
      this.inboundRtp = inboundRtp;

      // Spin up the RTP forker
      rtpFork.start();
      try {
        // Get the originator for the Page.
        InboundLeg origLeg = (InboundLeg) inbound;
        String pageOriginatorAddress;
        pageOriginatorAddress = origLeg.getAddress();

        // Answer the inbound call.
        inbound.acceptCall(rtpPort);

        // Start the timers
        if (maximumDuration > 0) {
          // Start the maximumDuration timer if it is greater than 0
          Timers.addTimer(
              "maximum_duration", maximumDuration, this); // End this page after this many mS
        }
        Timers.addTimer("beep_start", 1000, this); // Start the beep after this much time

        // Place a call to each destination
        for (String destination : destinations) {
          // Compare the originator with the destination.  Only place an outbound call
          // if they aren't the same.  We don't make a call to the same destination that
          // is initiating the page.
          if (destination.compareToIgnoreCase(pageOriginatorAddress) != 0) {
            Leg outbound =
                placeCall(inbound.getDisplayName(), origLeg.getCallId(), destination, alertInfoKey);
            if (outbound != null) {
              // Keep track of them!
              outbounds.add(outbound);
            }
          } else {
            LOG.info(
                String.format("Skipping %s as it is the page originator.", pageOriginatorAddress));
          }
        }
        return true;
      } catch (Throwable t) {
        LOG.warn("PageGroup::page", t);
        end();
      }
    }
    LOG.debug("PageGroup::page failed");
    return false;
  }