Package javax.sip.message

Examples of javax.sip.message.Response

  • 2xx: Success -- the action was successfully received, understood, and accepted.
  • 3xx: Redirection -- further action needs to be taken in order to complete the request; 3xx responses give information about the user's new location, or about alternative services that might be able to satisfy the call.
  • 4xx: Client Error -- the request contains bad syntax or cannot be fulfilled at this server; 4xx responses are definite failure responses from a particular server. The client SHOULD NOT retry the same request without modification. However, the same request to a different server might be successful.
  • 5xx: Server Error -- the server failed to fulfill an apparently valid request; 5xx responses are failure responses given when a server itself has erred.
  • 6xx: Global Failure -- the request cannot be fulfilled at any server; 6xx responses indicate that a server has definitive information about a particular user, not just the particular instance indicated in the Request-URI. SIP status codes are extensible. The response codes are consistent with, and extend, HTTP/1.1 response codes. Not all HTTP/1.1 response codes are appropriate, and only those that are appropriate are given here. Other HTTP/1.1 response codes SHOULD NOT be used. Also, SIP defines a new class, 6xx.

    SIP applications are not required to understand the meaning of all registered response codes, though such understanding is obviously desirable. However, applications must understand the class of any status code, as indicated by the first digit and outlined above. Applications treat any unrecognized status code as being equivalent to the x00 status code of that class, with the exception that an unrecognized status code must not be cached. For example, if a client receives an unrecognized status code of 431, it can safely assume that there was something wrong with its request and treat the Response as if it had received a BAD_REQUEST(400) status code. In such cases, user agents should present to the user the message body returned with the Response, since that message body is likely to include human-readable information which will explain the unusual status.

    This specification supports the response codes defined in RFC3261 and also the response code extensions for the event notification framework and PUBLISH, documented in RFC3265 and RFC3909, these are highlighted in italic. Class status codes (x00, i.e. 100) are are highlighted in bold.

    Class Code
    PROVISIONAL (1xx)
  • TRYING - 100
  • RINGING - 180
  • CALL_IS_BEING_FORWARDED - 181
  • QUEUED - 182
  • SESSION_PROGRESS - 183
  • SUCCESS (2xx)
  • OK - 200
  • ACCEPTED - 202 (Extension RFC3265)
  • REDIRECTION (3xx)
  • MULTIPLE_CHOICES - 300
  • MOVED_PERMANENTLY - 301
  • MOVED_TEMPORARILY - 302
  • USE_PROXY - 305
  • ALTERNATIVE_SERVICE - 380
  • CLIENT_ERROR (4xx)
  • BAD_REQUEST - 400
  • UNAUTHORIZED - 401
  • PAYMENT_REQUIRED - 402
  • FORBIDDEN - 403
  • NOT_FOUND - 404
  • METHOD_NOT_ALLOWED - 405
  • NOT_ACCEPTABLE - 406
  • PROXY_AUTHENTICATION_REQUIRED - 407
  • REQUEST_TIMEOUT - 408
  • GONE - 410
  • CONDITIONAL_REQUEST_FAILED - 412 (Extension RFC3909)
  • REQUEST_ENTITY_TOO_LARGE - 413
  • REQUEST_URI_TOO_LONG - 414
  • UNSUPPORTED_MEDIA_TYPE - 415
  • UNSUPPORTED_URI_SCHEME - 416
  • BAD_EXTENSION - 420
  • EXTENSION_REQUIRED - 421
  • INTERVAL_TOO_BRIEF - 423
  • TEMPORARILY_UNAVAILABLE - 480
  • CALL_OR_TRANSACTION_DOES_NOT_EXIST - 481
  • LOOP_DETECTED - 482
  • TOO_MANY_HOPS - 483
  • ADDRESS_INCOMPLETE - 484
  • AMBIGUOUS - 485
  • BUSY_HERE - 486
  • REQUEST_TERMINATED - 487
  • NOT_ACCEPTABLE_HERE - 488
  • BAD EVENT - 489 (Extension RFC3265)
  • REQUEST_PENDING - 491
  • UNDECIPHERABLE - 493
  • SERVER_ERROR (5xx)
  • SERVER_INTERNAL_ERROR - 500
  • NOT_IMPLEMENTED - 501
  • BAD_GATEWAY - 502
  • SERVICE_UNAVAILABLE - 503
  • SERVER_TIMEOUT - 504
  • VERSION_NOT_SUPPORTED - 505
  • MESSAGE_TOO_LARGE - 513
  • GLOBAL_ERROR (6xx)
  • BUSY_EVERYWHERE - 600
  • DECLINE - 603
  • DOES_NOT_EXIST_ANYWHERE - 604
  • SESSION_NOT_ACCEPTABLE - 606
  • @author BEA Systems, NIST @version 1.2

  •                 // System.exit(0);
                }
            }

            public synchronized void processResponse(ResponseEvent responseReceivedEvent) {
                Response response = (Response) responseReceivedEvent.getResponse();
                Transaction tid = responseReceivedEvent.getClientTransaction();

                if (response.getStatusCode() != 200) {
                    this.notifyCount--;
                } else {
                    System.out.println("Notify Count = " + this.notifyCount);
                }
    View Full Code Here


          // headers)
          if (!challenged) {
            challenged = true;
            ChallengeTest.assertNull(requestEvent.getServerTransaction());

            Response challenge = protocolObjects.messageFactory
                .createResponse(401, request);
            ToHeader toHeader = (ToHeader) challenge
                .getHeader(ToHeader.NAME);
            toHeader.setTag("challenge");
            sipProvider.sendResponse(challenge); // dont create ST
            return;
          }

          logger.info("shootme: got an Invite sending OK");
          // logger.info("shootme: " + request);
          Response response = protocolObjects.messageFactory.createResponse(
              180, request);
          ToHeader toHeader = (ToHeader) response.getHeader(ToHeader.NAME);
          toHeader.setTag("4321");
          Address address = protocolObjects.addressFactory
              .createAddress("Shootme <sip:" + myAddress + ":" + myPort
                  + ">");
          ContactHeader contactHeader = protocolObjects.headerFactory
              .createContactHeader(address);
          response.addHeader(contactHeader);
          ServerTransaction st = requestEvent.getServerTransaction();

          if (st == null) {
            st = sipProvider.getNewServerTransaction(request);
            logger.info("Server transaction created!" + request);

            logger.info("Dialog = " + st.getDialog());
            if (st.getDialog().getApplicationData() == null) {
              st.getDialog().setApplicationData(new ApplicationData());
            }
          } else {
            // If Server transaction is not null, then
            // this is a re-invite.
            logger.info("This is a RE INVITE ");
            ChallengeTest.assertSame("Dialog mismatch ", st.getDialog(),
                this.dialog);
          }

          // Thread.sleep(5000);
          logger.info("got a server tranasaction " + st);
          byte[] content = request.getRawContent();
          if (content != null) {
            logger.info(" content = " + new String(content));
            ContentTypeHeader contentTypeHeader = protocolObjects.headerFactory
                .createContentTypeHeader("application", "sdp");
            logger.info("response = " + response);
            response.setContent(content, contentTypeHeader);
          }
          dialog = st.getDialog();
          if (dialog != null) {
            logger.info("Dialog " + dialog);
            logger.info("Dialog state " + dialog.getState());
          }
          st.sendResponse(response);
          response = protocolObjects.messageFactory.createResponse(200,
              request);
          toHeader = (ToHeader) response.getHeader(ToHeader.NAME);
          toHeader.setTag("4321");
          // Application is supposed to set.
          response.addHeader(contactHeader);
          st.sendResponse(response);
          logger.info("TxState after sendResponse = " + st.getState());
        } catch (Exception ex) {
          String s = "unexpected exception";
    View Full Code Here

          // JvB: first time, challenge with 401 response (without proper
          // headers)
          if (!challengedBye) {
            challengedBye = true;
            logger.info("Got a BYE! Challenging...");
            Response challenge = protocolObjects.messageFactory
                .createResponse(401, request);
            serverTransactionId.sendResponse(challenge);
            return;
          }
         
          logger.info("shootme:  got a bye sending OK.");
          Response response = protocolObjects.messageFactory.createResponse(
              200, request);
          if (serverTransactionId != null) {
            serverTransactionId.sendResponse(response);
            logger.info("Dialog State is "
                + serverTransactionId.getDialog().getState());
    View Full Code Here

        }
      }

      public void processResponse(ResponseEvent responseReceivedEvent) {
        logger.info("Got a response");
        Response response = (Response) responseReceivedEvent.getResponse();
        Transaction tid = responseReceivedEvent.getClientTransaction();

        logger.info("Response received with client transaction id " + tid
            + ":\n" + response);
        try {
          if (response.getStatusCode() == Response.OK
              && ((CSeqHeader) response.getHeader(CSeqHeader.NAME))
                  .getMethod().equals(Request.INVITE)) {
            ChallengeTest.assertNotNull(
                "INVITE 200 response should match a transaction", tid);
            Dialog dialog = tid.getDialog();
            CSeqHeader cseq = (CSeqHeader) response
                .getHeader(CSeqHeader.NAME);
            Request request = dialog.createAck(cseq.getSeqNumber());
            dialog.sendAck(request);
          }
          if (tid != null) {
    View Full Code Here

                 * Got an UPDATE method and the user dialog does not exist and the user wants to be a
                 * User agent.
                 *
                 */
                if (sipProvider.isAutomaticDialogSupportEnabled() && dialog == null) {
                    Response notExist = sipRequest
                            .createResponse(Response.CALL_OR_TRANSACTION_DOES_NOT_EXIST);
                    try {
                        sipProvider.sendResponse(notExist);
                    } catch (SipException e) {
                        sipStack.getLogWriter().logError("error sending response", e);
                    }
                    if (transaction != null) {
                        sipStack.removeTransaction(transaction);
                        transaction.releaseSem();
                    }
                    return;
                }
            } else if (sipRequest.getMethod().equals(Request.ACK)) {

                if (transaction != null && transaction.isInviteTransaction()) {
                    // This is an ack for a 3xx-6xx response. Just let the tx laer
                    // take care of it.
                    if (sipStack.isLoggingEnabled())
                        sipStack.getLogWriter().logDebug("Processing ACK for INVITE Tx ");

                } else {
                    if (sipStack.isLoggingEnabled())
                        sipStack.getLogWriter().logDebug("Processing ACK for dialog " + dialog);

                    if (dialog == null) {
                        if (sipStack.isLoggingEnabled()) {
                            sipStack.getLogWriter().logDebug(
                                    "Dialog does not exist " + sipRequest.getFirstLine()
                                            + " isServerTransaction = " + true);

                        }
                        SIPServerTransaction st = sipStack
                                .getRetransmissionAlertTransaction(dialogId);
                        if (st != null && st.isRetransmissionAlertEnabled()) {
                            st.disableRetransmissionAlerts();

                        }
                        /*
                         * JvB: must never drop ACKs that dont match a transaction! One cannot be sure
                         * if it isn't an ACK for a 2xx response
                         *
                         */

                    } else {
                        if (!dialog.handleAck(transaction)) {
                          if(sipStack.isLooseDialogValidation()) {
                                if (sipStack.isLoggingEnabled()) {
                                    sipStack.getLogWriter().logDebug(
                                            "Dialog exists with loose dialog validation " + sipRequest.getFirstLine()
                                                    + " isServerTransaction = " + true + " dialog = " + dialog.getDialogId());

                                }
                                SIPServerTransaction st = sipStack
                                        .getRetransmissionAlertTransaction(dialogId);
                                if (st != null && st.isRetransmissionAlertEnabled()) {
                                    st.disableRetransmissionAlerts();

                                }
                          } else {
                            return;
                          }
                        } else {
                            transaction.passToListener();
                            dialog.addTransaction(transaction);
                            dialog.addRoute(sipRequest);
                            transaction.setDialog(dialog, dialogId);
                            if (sipStack.isDialogCreated(sipRequest.getMethod())) {
                                sipStack.putInMergeTable(transaction, sipRequest);
                            }
                            /*
                             * Note that ACK is a pseudo transaction. It is never added to the stack
                             * and you do not get transaction terminated events on ACK.
                             */

                            if (sipStack.deliverTerminatedEventForAck) {
                                try {
                                    sipStack.addTransaction(transaction);
                                    transaction.scheduleAckRemoval();
                                } catch (IOException ex) {

                                }
                            } else {
                                transaction.setMapped(true);
                            }

                            /*
                             * try { sipStack.addTransaction(transaction); } catch (IOException ex) { //
                             * should never happen. }
                             */

                        }
                    }
                }
            } else if (sipRequest.getMethod().equals(Request.PRACK)) {

                /*
                 * RFC 3262: A matching PRACK is defined as one within the same dialog as the
                 * response, and whose method, CSeq-num, and response-num in the RAck header field
                 * match, respectively, the method from the CSeq, the sequence number from the CSeq,
                 * and the sequence number from the RSeq of the reliable provisional response.
                 */

                if (sipStack.isLoggingEnabled())
                    sipStack.getLogWriter().logDebug("Processing PRACK for dialog " + dialog);

                if (dialog == null && sipProvider.isAutomaticDialogSupportEnabled()) {
                    if (sipStack.isLoggingEnabled()) {
                        sipStack.getLogWriter().logDebug(
                                "Dialog does not exist " + sipRequest.getFirstLine()
                                        + " isServerTransaction = " + true);

                    }
                    if (sipStack.isLoggingEnabled()) {
                        sipStack
                                .getLogWriter()
                                .logDebug(
                                        "Sending 481 for PRACK - automatic dialog support is enabled -- cant find dialog!");
                    }
                    SIPResponse notExist = sipRequest
                            .createResponse(Response.CALL_OR_TRANSACTION_DOES_NOT_EXIST);

                    try {
                        sipProvider.sendResponse(notExist);
                    } catch (SipException e) {
                        sipStack.getLogWriter().logError("error sending response", e);
                    }
                    if (transaction != null) {
                        sipStack.removeTransaction(transaction);
                        transaction.releaseSem();
                    }
                    return;

                } else if (dialog != null) {
                    if (!dialog.handlePrack(sipRequest)) {
                        sipStack.getLogWriter().logDebug("Dropping out of sequence PRACK ");
                        if (transaction != null) {
                            sipStack.removeTransaction(transaction);
                            transaction.releaseSem();
                        }
                        return;
                    } else {
                        try {
                            sipStack.addTransaction(transaction);
                            dialog.addTransaction(transaction);
                            dialog.addRoute(sipRequest);
                            transaction.setDialog(dialog, dialogId);
                        } catch (Exception ex) {
                            InternalErrorHandler.handleException(ex);
                        }
                    }
                } else {
                    sipStack.getLogWriter().logDebug(
                            "Processing PRACK without a DIALOG -- this must be a proxy element");
                }

            } else if (sipRequest.getMethod().equals(Request.BYE)) {
                // Check for correct sequence numbering of the BYE
                if (dialog != null && !dialog.isRequestConsumable(sipRequest)) {
                    if (sipStack.isLoggingEnabled())
                        sipStack.getLogWriter().logDebug(
                                "Dropping out of sequence BYE " + dialog.getRemoteSeqNumber() + " "
                                        + sipRequest.getCSeq().getSeqNumber());

                    if (dialog.getRemoteSeqNumber() >= sipRequest.getCSeq().getSeqNumber()
                            && transaction.getState() == TransactionState.TRYING) {

                        this.send500Response(sipRequest, transaction);

                    }
                    // If the stack knows about the tx, then remove it.
                    if (transaction != null)
                        sipStack.removeTransaction(transaction);
                    return;

                } else if (dialog == null && sipProvider.isAutomaticDialogSupportEnabled()) {
                    // Drop bye's with 481 if dialog does not exist.
                    // If dialog support is enabled then
                    // there must be a dialog associated with the bye
                    // No dialog could be found and requests on this
                    // provider. Must act like a user agent -- so drop the request.
                    // NOTE: if Automatic dialog support is not enabled,
                    // then it is the application's responsibility to
                    // take care of this error condition possibly.

                    SIPResponse response = sipRequest
                            .createResponse(Response.CALL_OR_TRANSACTION_DOES_NOT_EXIST);
                    response.setReasonPhrase("Dialog Not Found");

                    sipStack.getLogWriter().logDebug(
                            "dropping request -- automatic dialog "
                                    + "support enabled and dialog does not exist!");
                    try {
                        transaction.sendResponse(response);
                    } catch (SipException ex) {
                        sipStack.getLogWriter().logError("Error in sending response", ex);
                    }
                    // If the stack knows about the tx, then remove it.
                    if (transaction != null) {
                        sipStack.removeTransaction(transaction);
                        transaction.releaseSem();
                        transaction = null;
                    }
                    return;

                }

                // note that the transaction may be null (which
                // happens when no dialog for the bye was found.
                // and automatic dialog support is disabled (i.e. the app wants
                // to manage its own dialog layer.
                if (transaction != null && dialog != null) {
                    try {
                        if (sipProvider == dialog.getSipProvider()) {
                            sipStack.addTransaction(transaction);
                            dialog.addTransaction(transaction);
                            transaction.setDialog(dialog, dialogId);
                        }

                    } catch (IOException ex) {
                        InternalErrorHandler.handleException(ex);
                    }
                }
                if (sipStack.getLogWriter().isLoggingEnabled()) {
                    sipStack.getLogWriter().logDebug(
                            "BYE Tx = " + transaction + " isMapped ="
                                    + transaction.isTransactionMapped());
                }

            } else if (sipRequest.getMethod().equals(Request.CANCEL)) {

                SIPServerTransaction st = (SIPServerTransaction) sipStack.findCancelTransaction(
                        sipRequest, true);
                if (sipStack.getLogWriter().isLoggingEnabled()) {
                    sipStack.getLogWriter().logDebug(
                            "Got a CANCEL, InviteServerTx = " + st + " cancel Server Tx ID = "
                                    + transaction + " isMapped = "
                                    + transaction.isTransactionMapped());

                }
                // Processing incoming CANCEL.
                // Check if we can process the CANCEL request.
                if (sipRequest.getMethod().equals(Request.CANCEL)) {
                    // If the CANCEL comes in too late, there's not
                    // much that the Listener can do so just do the
                    // default action and avoid bothering the listener.
                    if (st != null && st.getState() == SIPTransaction.TERMINATED_STATE) {
                        // If transaction already exists but it is
                        // too late to cancel the transaction then
                        // just respond OK to the CANCEL and bail.
                        if (sipStack.isLoggingEnabled())
                            sipStack.getLogWriter().logDebug("Too late to cancel Transaction");
                        // send OK and just ignore the CANCEL.
                        try {

                            transaction.sendResponse(sipRequest.createResponse(Response.OK));
                        } catch (Exception ex) {
                            if (ex.getCause() != null && ex.getCause() instanceof IOException) {
                                st.raiseIOExceptionEvent();
                            }
                        }
                        return;
                    }
                    if (sipStack.isLoggingEnabled())
                        sipStack.getLogWriter().logDebug("Cancel transaction = " + st);

                }
                if (transaction != null && st != null && st.getDialog() != null) {
                    // Found an invite tx corresponding to the CANCEL.
                    // Set up the client tx and pass up to listener.
                    transaction.setDialog((SIPDialog) st.getDialog(), dialogId);
                    dialog = (SIPDialog) st.getDialog();
                } else if (st == null && sipProvider.isAutomaticDialogSupportEnabled()
                        && transaction != null) {
                    // Could not find a invite tx corresponding to the CANCEL.
                    // Automatic dialog support is enabled so I must behave like
                    // an endpoint on this provider.
                    // Send the error response for the cancel.

                    SIPResponse response = sipRequest
                            .createResponse(Response.CALL_OR_TRANSACTION_DOES_NOT_EXIST);
                    if (sipStack.isLoggingEnabled()) {
                        sipStack.getLogWriter().logDebug(
                                "dropping request -- automatic dialog support "
                                        + "enabled and INVITE ST does not exist!");
                    }
                    try {
                        sipProvider.sendResponse(response);
                    } catch (SipException ex) {
                        InternalErrorHandler.handleException(ex);
                    }
                    if (transaction != null) {
                        sipStack.removeTransaction(transaction);
                        transaction.releaseSem();
                    }
                    return;

                }

                // INVITE was handled statefully so the CANCEL must also be
                // statefully handled.
                if (st != null) {
                    try {
                        if (transaction != null) {
                            sipStack.addTransaction(transaction);
                            transaction.setPassToListener();
                            transaction.setInviteTransaction(st);
                            // Dont let the INVITE and CANCEL be concurrently
                            // processed.
                            st.acquireSem();

                        }

                    } catch (Exception ex) {
                        InternalErrorHandler.handleException(ex);
                    }
                }
            } else if (sipRequest.getMethod().equals(Request.INVITE)) {
                SIPTransaction lastTransaction = dialog == null ? null : dialog
                        .getInviteTransaction();

                /*
                 * RFC 3261 Chapter 14. A UAS that receives a second INVITE before it sends the final
                 * response to a first INVITE with a lower CSeq sequence number on the same dialog
                 * MUST return a 500 (Server Internal Error) response to the second INVITE and MUST
                 * include a Retry-After header field with a randomly chosen value of between 0 and 10
                 * seconds.
                 */

                if (dialog != null && transaction != null && lastTransaction != null
                        && sipRequest.getCSeq().getSeqNumber() > dialog.getRemoteSeqNumber()
                        && lastTransaction instanceof SIPServerTransaction
                        && lastTransaction.isInviteTransaction()
                        && lastTransaction.getState() != TransactionState.COMPLETED
                        && lastTransaction.getState() != TransactionState.TERMINATED
                        && lastTransaction.getState() != TransactionState.CONFIRMED) {

                    if (sipStack.isLoggingEnabled())
                        sipStack.getLogWriter().logDebug(
                                "Sending 500 response for out of sequence message");
                    SIPResponse sipResponse = sipRequest
                            .createResponse(Response.SERVER_INTERNAL_ERROR);

                    RetryAfter retryAfter = new RetryAfter();
                    try {
                        retryAfter.setRetryAfter((int) (10 * Math.random()));
                    } catch (InvalidArgumentException ex) {
                        ex.printStackTrace();
                    }
                    sipResponse.addHeader(retryAfter);
                    try {
                        transaction.sendMessage(sipResponse);
                    } catch (IOException ex) {
                        transaction.raiseIOExceptionEvent();
                    }
                    return;
                }

                /*
                 * RFC 3261 Chapter 14. A UAS that receives an INVITE on a dialog while an INVITE it
                 * had sent on that dialog is in progress MUST return a 491 (Request Pending) response
                 * to the received INVITE.
                 */

                lastTransaction = (dialog == null ? null : dialog.getLastTransaction());

                if (dialog != null && lastTransaction != null
                        && lastTransaction.isInviteTransaction()
                        && lastTransaction instanceof SIPClientTransaction
                        && lastTransaction.getState() != TransactionState.COMPLETED
                        && lastTransaction.getState() != TransactionState.TERMINATED) {

                    if (dialog.getRemoteSeqNumber() + 1 == sipRequest.getCSeq().getSeqNumber()) {
                        dialog.setRemoteSequenceNumber(sipRequest.getCSeq().getSeqNumber());
                        if (sipStack.isLoggingEnabled())
                            sipStack.getLogWriter().logDebug(
                                    "Sending 491 response for out of sequence message");
                        SIPResponse sipResponse = sipRequest.createResponse(Response.REQUEST_PENDING);
                        try {
                            transaction.sendMessage(sipResponse);
                        } catch (IOException ex) {
                            transaction.raiseIOExceptionEvent();
                        }
                        dialog.requestConsumed();
                    } else {
                        if (sipStack.isLoggingEnabled())
                            sipStack.getLogWriter().logDebug(
                                    "Dropping message -- sequence number is too high!");
                    }
                    return;
                }
            }

            // Sequence numbers are supposed to be incremented
            // sequentially within a dialog for RFC 3261
            // Note BYE, CANCEL and ACK is handled above - so no check here.

            sipStack.getLogWriter().logDebug(
                    "CHECK FOR OUT OF SEQ MESSAGE " + dialog + " transaction " + transaction);

            if (dialog != null && transaction != null && !sipRequest.getMethod().equals(Request.BYE)
                    && !sipRequest.getMethod().equals(Request.CANCEL)
                    && !sipRequest.getMethod().equals(Request.ACK)
                    && !sipRequest.getMethod().equals(Request.PRACK)) {

                if (!dialog.isRequestConsumable(sipRequest)) {

                    /*
                     * RFC 3261: "UAS Behavior" section (12.2.2): If the remote sequence number was
                     * not empty, but the sequence number of the request is lower than the remote
                     * sequence number, the request is out of order and MUST be rejected with a 500
                     * (Server Internal Error) response.
                     */

                    // Drop the request
                    if (sipStack.isLoggingEnabled()) {
                        sipStack.getLogWriter().logDebug(
                                "Dropping out of sequence message " + dialog.getRemoteSeqNumber()
                                        + " " + sipRequest.getCSeq());
                    }

                    // send error when stricly higher, ignore when ==
                    // (likely still processing, error would interrupt that)
                    if (dialog.getRemoteSeqNumber() >= sipRequest.getCSeq().getSeqNumber()
                            && (transaction.getState() == TransactionState.TRYING || transaction
                                    .getState() == TransactionState.PROCEEDING)) {

                        this.send500Response(sipRequest, transaction);

                    }
                    return;
                }

                try {
                    if (sipProvider == dialog.getSipProvider()) {
                        sipStack.addTransaction(transaction);
                        // This will set the remote sequence number.
                        dialog.addTransaction(transaction);
                        dialog.addRoute(sipRequest);
                        transaction.setDialog(dialog, dialogId);

                    }
                } catch (IOException ex) {
                    transaction.raiseIOExceptionEvent();
                    sipStack.removeTransaction(transaction);
                    return;
                }

            }

            RequestEvent sipEvent;

            if (sipStack.getLogWriter().isLoggingEnabled()) {

                sipStack.getLogWriter().logDebug(
                        sipRequest.getMethod() + " transaction.isMapped = "
                                + transaction.isTransactionMapped());
            }

            /*
             * RFC 3265: Each event package MUST specify whether forked SUBSCRIBE requests are allowed
             * to install multiple subscriptions. If such behavior is not allowed, the first potential
             * dialog- establishing message will create a dialog. All subsequent NOTIFY messages which
             * correspond to the SUBSCRIBE message (i.e., match "To", "From", "From" header "tag"
             * parameter, "Call-ID", "CSeq", "Event", and "Event" header "id" parameter) but which do
             * not match the dialog would be rejected with a 481 response. Note that the 200-class
             * response to the SUBSCRIBE can arrive after a matching NOTIFY has been received; such
             * responses might not correlate to the same dialog established by the NOTIFY. Except as
             * required to complete the SUBSCRIBE transaction, such non-matching 200-class responses
             * are ignored.
             */

            if (dialog == null && sipRequest.getMethod().equals(Request.NOTIFY)) {

                SIPClientTransaction pendingSubscribeClientTx = sipStack.findSubscribeTransaction(
                        sipRequest, listeningPoint);

                if (sipStack.getLogWriter().isLoggingEnabled()) {
                    sipStack.getLogWriter().logDebug(
                            "PROCESSING NOTIFY  DIALOG == null " + pendingSubscribeClientTx);
                }

                /*
                 * RFC 3265: Upon receiving a NOTIFY request, the subscriber should check that it
                 * matches at least one of its outstanding subscriptions; if not, it MUST return a
                 * "481 Subscription does not exist" response unless another 400- or 500-class
                 * response is more appropriate.
                 */
                if (sipProvider.isAutomaticDialogSupportEnabled() && pendingSubscribeClientTx == null
                        && !sipStack.deliverUnsolicitedNotify) {
                    /*
                     * This is the case of the UAC receiving a Stray NOTIFY for which it has not
                     * previously sent out a SUBSCRIBE and for which it does not have an established
                     * dialog.
                     */
                    try {
                        if (sipStack.isLoggingEnabled()) {
                            sipStack.getLogWriter().logDebug(
                                    "Could not find Subscription for Notify Tx.");
                        }
                        Response errorResponse = sipRequest
                                .createResponse(Response.CALL_OR_TRANSACTION_DOES_NOT_EXIST);
                        errorResponse.setReasonPhrase("Subscription does not exist");
                        sipProvider.sendResponse(errorResponse);
                        return;

                    } catch (Exception ex) {
                        sipStack.getLogWriter().logError(
    View Full Code Here

            logger.info("shootist:  null TID.");
            return;
          }
          Dialog dialog = serverTransactionId.getDialog();
          logger.info("Dialog State = " + dialog.getState());
          Response response = protocolObjects.messageFactory.createResponse(
              200, request);
          serverTransactionId.sendResponse(response);
          logger.info("shootist:  Sending OK.");
          logger.info("Dialog State = " + dialog.getState());
    View Full Code Here

        }
      }

      public synchronized void processResponse(ResponseEvent responseReceivedEvent) {
        logger.info("Got a response");
        Response response = (Response) responseReceivedEvent.getResponse();
        ClientTransaction tid = responseReceivedEvent.getClientTransaction();
        CSeqHeader cseq = (CSeqHeader) response.getHeader(CSeqHeader.NAME);

        logger.info("Response received : Status Code = "
            + response.getStatusCode() + " " + cseq);
        logger.info("Response = " + response + " class=" + response.getClass() );

        Dialog dialog = responseReceivedEvent.getDialog();
        TestHarness.assertNotNull( dialog )
       
        if (tid != null)
          logger.info("transaction state is " + tid.getState());
        else
          logger.info("transaction = " + tid);

        logger.info("Dialog = " + dialog);

        logger.info("SHOOTIST: Dialog state is " + dialog.getState());

        try {
          if (response.getStatusCode() == Response.OK) {
            if (cseq.getMethod().equals(Request.INVITE)) {
              TestHarness.assertEquals( DialogState.CONFIRMED, dialog.getState() );
                     
             
              Request ackRequest = dialog.createAck(cseq
                                .getSeqNumber());
                       
                        TestHarness.assertNotNull( ackRequest.getHeader( MaxForwardsHeader.NAME ) );
       
              // Proxy will fork. I will accept the second dialog
              // but not the first.
              this.forkedDialogs.add(dialog);
              dialog.sendAck(ackRequest);
              if ( forkedDialogs.size() == 2 ) {
                logger.info("Sending ACK");
               
                TestHarness.assertTrue(
                    "Dialog state should be CONFIRMED", dialog
                        .getState() == DialogState.CONFIRMED);
                this.ackedDialog = dialog;
               
                // TestHarness.assertNotNull( "JvB: Need CT to find original dialog", tid );

              } else {
               
                // Kill the first dialog by sending a bye.
                SipProvider sipProvider = (SipProvider) responseReceivedEvent
                    .getSource();
                Request byeRequest = dialog.createRequest(Request.BYE);
                ClientTransaction ct = sipProvider
                    .getNewClientTransaction(byeRequest);
                dialog.sendRequest(ct);         
              }
             
             
            } else {
              logger.info("Response method = " + cseq.getMethod());
            }
          } else if ( response.getStatusCode() == Response.RINGING ) {
            //TestHarness.assertEquals( DialogState.EARLY, dialog.getState() );
          }
        } catch (Throwable ex) {
          ex.printStackTrace();
          // System.exit(0);
    View Full Code Here

      }

      public void processResponse(ResponseEvent responseEvent) {
        try {
          Response response = responseEvent.getResponse();
          CSeqHeader cseq = (CSeqHeader) response.getHeader(CSeqHeader.NAME);
          logger.info("ClientTxID = "
              + responseEvent.getClientTransaction()
              + " client tx id "
              + ((ViaHeader) response.getHeader(ViaHeader.NAME))
                  .getBranch() + " CSeq header = "
              + response.getHeader(CSeqHeader.NAME) + " status code = "
              + response.getStatusCode());

          // JvB: stateful proxy MUST NOT forward 100 Trying
          if (response.getStatusCode() == 100)
            return;

          if (cseq.getMethod().equals(Request.INVITE)) {
            ClientTransaction ct = responseEvent.getClientTransaction();
            if (ct != null) {
              ServerTransaction st = (ServerTransaction) ct
                  .getApplicationData();

              // Strip the topmost via header
              Response newResponse = (Response) response.clone();
              newResponse.removeFirst(ViaHeader.NAME);
              // The server tx goes to the terminated state.

              st.sendResponse(newResponse);
            } else {
              // Client tx has already terminated but the UA is
              // retransmitting
              // just forward the response statelessly.
              // Strip the topmost via header

              Response newResponse = (Response) response.clone();
              newResponse.removeFirst(ViaHeader.NAME);
              // Send the retransmission statelessly
             
              this.inviteServerTxProvider.sendResponse(newResponse);
             
            }
    View Full Code Here

                Request request = requestEvent.getRequest();
                Dialog dialog = requestEvent.getDialog();
                logger.info("shootme: local party = " + dialog.getLocalParty());
                try {
                    logger.info("shootme:  got a bye sending OK.");
                    Response response = messageFactory.createResponse(200, request);
                    serverTransactionId.sendResponse(response);
                    logger.info("shootme: Dialog State is "
                            + serverTransactionId.getDialog().getState());

                } catch (Exception ex) {
    View Full Code Here

                    if (dialog != null) {
                        logger.info("Dialog State = " + dialog.getState());
                    }

                    Response response = messageFactory.createResponse(200, notify);
                    // SHOULD add a Contact
                    ContactHeader contact = (ContactHeader) contactHeader.clone();
                    ((SipURI) contact.getAddress().getURI()).setParameter("id", "sub");
                    response.addHeader(contact);
                    logger.info("Transaction State = " + serverTransactionId.getState());
                    serverTransactionId.sendResponse(response);
                    if (dialog != null) {
                        logger.info("Dialog State = " + dialog.getState());
                    }
    View Full Code Here

    TOP

    Related Classes of javax.sip.message.Response

    Copyright © 2018 www.massapicom. All rights reserved.
    All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.