コード例 #1
0
  /**
   * @param originalRequestEvent
   * @param response
   * @param serviceUnit
   */
  @Override
  public void sendResponse(
      RequestEvent originalRequestEvent, Response response, ServiceUnit serviceUnit, String toTag) {
    /** Here we need to do some specific handling specific to the type of responses being sent. */

    /**
     * If it is a 180 RINGING response, then we need to set the To tag to the same to tag generated
     * when creating the associated B2BSession and B2BDialog.
     */
    if (isDialogCreating(response.getStatusCode())) {
      logger.fine("Sending a ringing response...");
      /** Copy the Local Tag from the B2BDialog to the SipResponse */
      logger.info("Setting the To Dialog of the response to be sent to : " + toTag);
      SIPResponse sipResponse = (SIPResponse) response;
      sipResponse.setToTag(toTag);
    }
    logger.info(
        "Sending Response for the request associated with ServiceUnit: " + serviceUnit.getName());
    /** Conveying the response sending to the UserAgent */
    logger.info("Sending Response: " + response.getReasonPhrase());
    Dialog sipDialog = userAgent.sendResponse(originalRequestEvent, response, serviceUnit);
    if (sipDialog == null) {
      logger.info(
          "The sent response " + response.getReasonPhrase() + " did not resulted in any dialog...");
    } else {
      logger.info(
          "The sent response "
              + response.getReasonPhrase()
              + " has created a new Dialog with ID: "
              + sipDialog.getDialogId());
    }
    /**
     * Set the underlying SIP Dialog of the B2BDialog for Dialog creating responses as well as the
     * local seq number and the current state of the dialog.
     */
    if (isDialogCreating(response.getStatusCode())) {
      B2BSession b2BSessions[] =
          RuntimeComponentContext.getInstance().getB2BSessions(serviceUnit.getName());
      for (B2BSession b2BSession : b2BSessions) {
        B2BDialogImpl b2BDialogImpl = null;
        if (sipDialog != null) {
          b2BDialogImpl =
              (B2BDialogImpl) b2BSession.getB2BDialog(sipDialog.getDialogId(), true, null);
        }
        if (b2BDialogImpl != null) {
          logger.info(
              "Setting the underlying SIP Dialog property of the B2BDialog: "
                  + b2BDialogImpl.getDialogId());
          b2BDialogImpl.setUnderlyingSipDialog(sipDialog);
          b2BDialogImpl.setLocalSeqNumber(sipDialog.getLocalSeqNumber());
          b2BDialogImpl.setState(sipDialog.getState().toString());
          logger.info(
              "Setting the Dialog status with ID: "
                  + b2BDialogImpl.getDialogId()
                  + " to "
                  + sipDialog.getState().toString());
          break;
        } else {
          logger.info("Unable to locate a B2BDialog with ID " + sipDialog.getDialogId());
        }
      }
    }
  }
コード例 #2
0
 /**
  * @param request
  * @param serviceUnit
  */
 @Override
 public void sendRequest(Request request, ServiceUnit serviceUnit) {
   logger.info("Sending Request: " + request.getMethod());
   userAgent.sendRequest(request, serviceUnit);
   logger.info("Sending Request that is associated with ServiceUnit: " + serviceUnit.getName());
 }