Search in sources :

Example 1 with ResponseEventExt

use of gov.nist.javax.sip.ResponseEventExt in project jain-sip.ha by RestComm.

the class SimpleB2BUAHandler method process200.

public void process200(ResponseEvent responseEvent) {
    boolean isRetransmission = ((ResponseEventExt) responseEvent).isRetransmission();
    ClientTransaction clientTransaction = ((ResponseEventExt) responseEvent).getClientTransaction();
    ((ClusteredSipStack) sipStack).getStackLogger().logDebug("clientTransaction = " + clientTransaction + ", isRetransmission " + isRetransmission);
    try {
        final CSeqHeader cSeqHeader = (CSeqHeader) responseEvent.getResponse().getHeader(CSeqHeader.NAME);
        if (cSeqHeader.getMethod().equals(Request.INVITE)) {
            processInvite200(responseEvent, cSeqHeader);
        } else if (cSeqHeader.getMethod().equals(Request.BYE) || cSeqHeader.getMethod().equals(Request.SUBSCRIBE) || cSeqHeader.getMethod().equals(Request.NOTIFY)) {
            processBye200(responseEvent);
        } else {
            System.err.println("Unexpected response: " + responseEvent.getResponse());
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : CSeqHeader(javax.sip.header.CSeqHeader) ClientTransaction(javax.sip.ClientTransaction) ResponseEventExt(gov.nist.javax.sip.ResponseEventExt) InvalidArgumentException(javax.sip.InvalidArgumentException) ParseException(java.text.ParseException) CacheException(org.jboss.cache.CacheException) SipException(javax.sip.SipException)

Example 2 with ResponseEventExt

use of gov.nist.javax.sip.ResponseEventExt in project jain-sip.ha by RestComm.

the class SimpleStatefulProxy method processInvite200.

/**
 * @param responseEvent
 * @throws SipException
 * @throws InvalidArgumentException
 */
private void processInvite200(ResponseEvent responseEvent, CSeqHeader cseq) throws InvalidArgumentException, SipException {
    // lets ack it ourselves to avoid UAS retransmissions due to
    // forwarding of this response and further UAC Ack
    // note that the app does not handles UAC ACKs
    // String outgoingDialogId = responseEvent.getDialog().getDialogId();
    int remotePort = ((ResponseEventExt) responseEvent).getRemotePort();
    if (ListeningPoint.TCP.equalsIgnoreCase(transport)) {
        remotePort = ((MessageExt) responseEvent.getResponse()).getTopmostViaHeader().getPort();
    }
    ((ClusteredSipStack) sipStack).getStackLogger().logDebug("remotePort = " + remotePort);
    // if(remotePort == 5065 || remotePort == 5081) {
    // storeOutgoingDialogId(outgoingDialogId);
    // }
    // if(myPort == 5080 && getOutgoingDialogId() == null) {
    // storeOutgoingDialogId(outgoingDialogId);
    // }
    forwardResponse(responseEvent.getResponse());
}
Also used : MessageExt(gov.nist.javax.sip.message.MessageExt) ResponseEventExt(gov.nist.javax.sip.ResponseEventExt) ListeningPoint(javax.sip.ListeningPoint)

Example 3 with ResponseEventExt

use of gov.nist.javax.sip.ResponseEventExt in project jain-sip.ha by RestComm.

the class SimpleB2BUAHandler method processInvite200.

/**
 * @param responseEvent
 * @throws SipException
 * @throws InvalidArgumentException
 */
private void processInvite200(ResponseEvent responseEvent, CSeqHeader cseq) throws InvalidArgumentException, SipException {
    // lets ack it ourselves to avoid UAS retransmissions due to
    // forwarding of this response and further UAC Ack
    // note that the app does not handles UAC ACKs
    String outgoingDialogId = responseEvent.getDialog().getDialogId();
    int remotePort = ((ResponseEventExt) responseEvent).getRemotePort();
    if (ListeningPoint.TCP.equalsIgnoreCase(transport)) {
        remotePort = ((MessageExt) responseEvent.getResponse()).getTopmostViaHeader().getPort();
    }
    ((ClusteredSipStack) sipStack).getStackLogger().logDebug("remotePort = " + remotePort);
    if (remotePort == 5065 || remotePort == 5081) {
        storeOutgoingDialogId(outgoingDialogId);
    }
    if (myPort == 5080 && getOutgoingDialogId() == null) {
        storeOutgoingDialogId(outgoingDialogId);
    }
    if (sendAckOn2xx) {
        System.out.println("Generating ACK to 200");
        final Request ack = responseEvent.getDialog().createAck(cseq.getSeqNumber());
        responseEvent.getDialog().sendAck(ack);
    }
    forwardResponse(responseEvent.getResponse());
}
Also used : MessageExt(gov.nist.javax.sip.message.MessageExt) Request(javax.sip.message.Request) SIPRequest(gov.nist.javax.sip.message.SIPRequest) ResponseEventExt(gov.nist.javax.sip.ResponseEventExt) ListeningPoint(javax.sip.ListeningPoint)

Example 4 with ResponseEventExt

use of gov.nist.javax.sip.ResponseEventExt in project jain-sip.ha by RestComm.

the class SimpleStatefulProxy method process200.

public void process200(ResponseEvent responseEvent) {
    try {
        boolean isRetransmission = ((ResponseEventExt) responseEvent).isRetransmission();
        ClientTransaction clientTransaction = ((ResponseEventExt) responseEvent).getClientTransaction();
        ((ClusteredSipStack) sipStack).getStackLogger().logDebug("clientTransaction = " + clientTransaction + ", isRetransmission " + isRetransmission);
        final CSeqHeader cSeqHeader = (CSeqHeader) responseEvent.getResponse().getHeader(CSeqHeader.NAME);
        if (cSeqHeader.getMethod().equals(Request.INVITE)) {
            processInvite200(responseEvent, cSeqHeader);
        } else if (cSeqHeader.getMethod().equals(Request.BYE) || cSeqHeader.getMethod().equals(Request.SUBSCRIBE) || cSeqHeader.getMethod().equals(Request.NOTIFY)) {
            processBye200(responseEvent);
        } else {
            System.err.println("Unexpected response: " + responseEvent.getResponse());
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : CSeqHeader(javax.sip.header.CSeqHeader) ClientTransaction(javax.sip.ClientTransaction) ResponseEventExt(gov.nist.javax.sip.ResponseEventExt) InvalidArgumentException(javax.sip.InvalidArgumentException) ParseException(java.text.ParseException) CacheException(org.jboss.cache.CacheException) SipException(javax.sip.SipException)

Example 5 with ResponseEventExt

use of gov.nist.javax.sip.ResponseEventExt in project jain-sip.ha by RestComm.

the class SimpleB2BUA method processResponse.

public void processResponse(ResponseEvent responseEvent) {
    Dialog dialog = responseEvent.getDialog();
    if (dialog != null) {
        System.out.println("dialog is " + dialog.getDialogId() + " for response " + responseEvent.getResponse());
        if (((ResponseEventExt) responseEvent).isRetransmission()) {
            // retransmission, drop it
            System.out.println("dropping retransmission for response " + responseEvent.getResponse() + "on dialog " + dialog.getDialogId());
            return;
        }
        if (b2buaHandler != null) {
            switch(responseEvent.getResponse().getStatusCode()) {
                case 100:
                    // ignore
                    break;
                case 180:
                    b2buaHandler.process180(responseEvent);
                    break;
                case 200:
                    b2buaHandler.process200(responseEvent);
                    break;
                case 202:
                    b2buaHandler.process200(responseEvent);
                    break;
                default:
                    System.err.println("Received unexpected sip response: " + responseEvent.getResponse());
                    dialog.setApplicationData(null);
                    break;
            }
        } else {
            ((SipStackImpl) sipStack).getStackLogger().logError("Received response on dialog with id that does not matches a active call: " + responseEvent.getResponse());
        }
    } else {
        ((SipStackImpl) sipStack).getStackLogger().logError("Received response without dialog: " + responseEvent.getResponse());
    }
}
Also used : Dialog(javax.sip.Dialog) ResponseEventExt(gov.nist.javax.sip.ResponseEventExt)

Aggregations

ResponseEventExt (gov.nist.javax.sip.ResponseEventExt)5 MessageExt (gov.nist.javax.sip.message.MessageExt)2 ParseException (java.text.ParseException)2 ClientTransaction (javax.sip.ClientTransaction)2 InvalidArgumentException (javax.sip.InvalidArgumentException)2 ListeningPoint (javax.sip.ListeningPoint)2 SipException (javax.sip.SipException)2 CSeqHeader (javax.sip.header.CSeqHeader)2 CacheException (org.jboss.cache.CacheException)2 SIPRequest (gov.nist.javax.sip.message.SIPRequest)1 Dialog (javax.sip.Dialog)1 Request (javax.sip.message.Request)1