Beispiel #1
0
  /**
   * Receive CANCEL request
   *
   * @param cancel CANCEL request
   */
  public void receiveCancel(SipRequest cancel) {
    if (logger.isActivated()) {
      logger.info("ABC Receive a CANCEL message from the remote");
    }

    if (getDialogPath().isSigEstablished()) {
      if (logger.isActivated()) {
        logger.info(
            "Ignore the received CANCEL message from the remote (session already established)");
      }
      return;
    }

    // Close media session
    closeMediaSession();

    // Update dialog path
    getDialogPath().sessionCancelled();

    // Send a 487 Request terminated
    try {
      if (logger.isActivated()) {
        logger.info("Send 487 Request terminated");
      }
      SipResponse terminatedResp =
          SipMessageFactory.createResponse(
              getDialogPath().getInvite(), getDialogPath().getLocalTag(), 487);
      getImsService().getImsModule().getSipManager().sendSipResponse(terminatedResp);
    } catch (Exception e) {
      if (logger.isActivated()) {
        logger.error("Can't send 487 error response", e);
      }
    }

    // Remove the current session
    getImsService().removeSession(this);

    // Set invitation status
    invitationStatus = ImsServiceSession.INVITATION_CANCELED;

    // Unblock semaphore
    synchronized (waitUserAnswer) {
      waitUserAnswer.notifyAll();
    }

    // Notify listeners
    for (int i = 0; i < getListeners().size(); i++) {
      getListeners().get(i).handleSessionTerminatedByRemote();
    }

    // Request capabilities to the remote
    getImsService()
        .getImsModule()
        .getCapabilityService()
        .requestContactCapabilities(getDialogPath().getRemoteParty());
  }
 /**
  * Send a 180 Ringing response to the remote party
  *
  * @param request SIP request
  * @param localTag Local tag
  */
 public void send180Ringing(SipRequest request, String localTag) {
   try {
     SipResponse progress = SipMessageFactory.createResponse(request, localTag, 180);
     getImsService().getImsModule().getSipManager().sendSipResponse(progress);
   } catch (Exception e) {
     if (logger.isActivated()) {
       logger.error("Can't send a 180 Ringing response");
     }
   }
 }
 /**
  * Send a 415 "Unsupported Media Type" to the remote party
  *
  * @param request SIP request
  */
 public void send415Error(SipRequest request) {
   try {
     if (logger.isActivated()) {
       logger.info("Send 415 Unsupported Media Type");
     }
     SipResponse resp = SipMessageFactory.createResponse(request, 415);
     // TODO: set Accept-Encoding header
     getImsService().getImsModule().getSipManager().sendSipResponse(resp);
   } catch (Exception e) {
     if (logger.isActivated()) {
       logger.error("Can't send 415 error response", e);
     }
   }
 }
 /**
  * Send a 486 "Busy" to the remote party
  *
  * @param request SIP request
  * @param localTag Local tag
  */
 public void send486Busy(SipRequest request, String localTag) {
   try {
     // Send a 486 Busy error
     if (logger.isActivated()) {
       logger.info("Send 486 Busy");
     }
     SipResponse resp = SipMessageFactory.createResponse(request, localTag, 486);
     getImsService().getImsModule().getSipManager().sendSipResponse(resp);
   } catch (Exception e) {
     if (logger.isActivated()) {
       logger.error("Can't send 486 Busy response", e);
     }
   }
 }
 /**
  * Send an error response to the remote party
  *
  * @param request SIP request
  * @param localTag Local tag
  * @param code Response code
  */
 public void sendErrorResponse(SipRequest request, String localTag, int code) {
   try {
     // Send  error
     if (logger.isActivated()) {
       logger.info("Send " + code + " error response");
     }
     SipResponse resp = SipMessageFactory.createResponse(request, localTag, code);
     getImsService().getImsModule().getSipManager().sendSipResponse(resp);
   } catch (Exception e) {
     if (logger.isActivated()) {
       logger.error("Can't send error response", e);
     }
   }
 }