Example #1
0
  /**
   * Responds with <i>resp</i>. This method can be called when the InviteDialog is in D_INVITED or
   * D_BYED states.
   *
   * <p>If the CSeq method is INVITE and the response is 2xx, it moves to state D_ACCEPTED, adds a
   * new listener to the SipProviderListener, and creates new AckTransactionServer
   *
   * <p>If the CSeq method is INVITE and the response is not 2xx, it moves to state D_REFUSED, and
   * sends the response.
   */
  public void respond(Message resp)
        // private void respond(Message resp)
      {
    printLog("inside respond(resp)", LogLevel.MEDIUM);
    String method = resp.getCSeqHeader().getMethod();
    if (method.equals(SipMethods.INVITE)) {
      if (!verifyStatus(statusIs(D_INVITED) || statusIs(D_ReINVITED))) {
        printLog(
            "respond(): InviteDialog not in (re)invited state: No response now", LogLevel.HIGH);
        return;
      }

      int code = resp.getStatusLine().getCode();
      // 1xx provisional responses
      if (code >= 100 && code < 200) {
        invite_ts.respondWith(resp);
        return;
      }
      // For all final responses establish the dialog
      if (code >= 200) { // changeStatus(D_ACCEPTED);
        update(Dialog.UAS, resp);
      }
      // 2xx success responses
      if (code >= 200 && code < 300) {
        if (statusIs(D_INVITED)) changeStatus(D_ACCEPTED);
        else changeStatus(D_ReACCEPTED);
        // terminates the INVITE Transaction server and activates an ACK
        // Transaction server
        invite_ts.terminate();
        ConnectionIdentifier conn_id = invite_ts.getConnectionId();
        ack_ts = new AckTransactionServer(sip_provider, conn_id, resp, this);
        ack_ts.respond();
        // if (statusIs(D_ReACCEPTED))
        // listener.onDlgReInviteAccepted(this);
        // else listener.onDlgAccepted(this);
        return;
      } else
      // 300-699 failure responses
      // if (code>=300)
      {
        if (statusIs(D_INVITED)) changeStatus(D_REFUSED);
        else changeStatus(D_ReREFUSED);
        invite_ts.respondWith(resp);
        // if (statusIs(D_ReREFUSED))
        // listener.onDlgReInviteRefused(this);
        // else listener.onDlgRefused(this);
        return;
      }
    }
    if (method.equals(SipMethods.BYE)) {
      if (!verifyStatus(statusIs(D_BYED))) return;
      bye_ts.respondWith(resp);
    }
  }
Example #2
0
 /** Starts a new InviteTransactionServer. */
 public void listen() {
   if (!statusIs(D_INIT)) return;
   // else
   changeStatus(D_WAITING);
   invite_ts = new InviteTransactionServer(sip_provider, this);
   invite_ts.listen();
 }
Example #3
0
 /**
  * Cancel the ongoing call request or a call listening. This method should be called when the
  * InviteDialog is in D_INVITING or D_ReINVITING state or in the D_WAITING state
  */
 public void cancel(Message cancel) {
   printLog("inside cancel(cancel)", LogLevel.MEDIUM);
   if (statusIs(D_INVITING) || statusIs(D_ReINVITING)) { // changeStatus(D_CANCELING);
     TransactionClient tc = new TransactionClient(sip_provider, cancel, null);
     tc.request();
   } else if (statusIs(D_WAITING) || statusIs(D_ReWAITING)) {
     invite_ts.terminate();
   }
 }
Example #4
0
 /**
  * Cancel the ongoing call request or a call listening. This method should be called when the
  * InviteDialog is in D_INVITING or D_ReINVITING state or in the D_WAITING state
  */
 public void cancel() {
   printLog("inside cancel()", LogLevel.MEDIUM);
   if (statusIs(D_INVITING) || statusIs(D_ReINVITING)) {
     Message cancel = MessageFactory.createCancelRequest(invite_req, this); // modified
     cancel(cancel);
   } else if (statusIs(D_WAITING) || statusIs(D_ReWAITING)) {
     invite_ts.terminate();
   }
 }