Search in sources :

Example 6 with MessageExt

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

the class SimpleB2BUAHandler method processBye.

public void processBye(RequestEvent requestEvent) {
    try {
        int remotePort = ((RequestEventExt) requestEvent).getRemotePort();
        if (ListeningPoint.TCP.equalsIgnoreCase(transport)) {
            remotePort = ((MessageExt) requestEvent.getRequest()).getTopmostViaHeader().getPort();
        }
        ((ClusteredSipStack) sipStack).getStackLogger().logDebug("remotePort = " + remotePort);
        requestEvent.getServerTransaction().sendResponse(messageFactory.createResponse(200, requestEvent.getRequest()));
        Dialog dialog = getOutgoingDialog();
        if (remotePort == 5060 || remotePort == 5065) {
            dialog = getIncomingDialog();
        }
        Request request = dialog.createRequest(Request.BYE);
        final ClientTransaction ct = sipProvider.getNewClientTransaction(request);
        dialog.sendRequest(ct);
    } catch (Exception e) {
        ((SipStackImpl) sipStack).getStackLogger().logError("unexpected exception", e);
    }
}
Also used : RequestEventExt(gov.nist.javax.sip.RequestEventExt) MessageExt(gov.nist.javax.sip.message.MessageExt) Dialog(javax.sip.Dialog) ClientTransaction(javax.sip.ClientTransaction) Request(javax.sip.message.Request) SIPRequest(gov.nist.javax.sip.message.SIPRequest) ListeningPoint(javax.sip.ListeningPoint) InvalidArgumentException(javax.sip.InvalidArgumentException) ParseException(java.text.ParseException) CacheException(org.jboss.cache.CacheException) SipException(javax.sip.SipException)

Example 7 with MessageExt

use of gov.nist.javax.sip.message.MessageExt 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 8 with MessageExt

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

the class SimpleStatefulProxy method processAck.

public void processAck(RequestEvent requestEvent) {
    int remotePort = ((RequestEventExt) requestEvent).getRemotePort();
    if (ListeningPoint.TCP.equalsIgnoreCase(transport)) {
        remotePort = ((MessageExt) requestEvent.getRequest()).getTopmostViaHeader().getPort();
    }
    ((ClusteredSipStack) sipStack).getStackLogger().logDebug("remotePort = " + remotePort);
    try {
        final Request ack = (Request) requestEvent.getRequest().clone();
        String branchId = getClientTransactionId();
        ack.addHeader(headerFactory.createViaHeader(ipAddress, myPort, transport, branchId));
        ((SipURI) ack.getRequestURI()).setPort(getClientTransactionPort());
        ack.removeLast(RouteHeader.NAME);
        RouteHeader routeHeader = (RouteHeader) ack.getHeader(RouteHeader.NAME);
        if (routeHeader != null && (((SipURI) routeHeader.getAddress().getURI()).getPort() == 5080 || ((SipURI) routeHeader.getAddress().getURI()).getPort() == 5081)) {
            ack.removeFirst(RouteHeader.NAME);
        }
        sipProvider.sendRequest(ack);
    } catch (Exception e) {
        ((SipStackImpl) sipStack).getStackLogger().logError("unexpected exception", e);
    }
}
Also used : RequestEventExt(gov.nist.javax.sip.RequestEventExt) MessageExt(gov.nist.javax.sip.message.MessageExt) RouteHeader(javax.sip.header.RouteHeader) RecordRouteHeader(javax.sip.header.RecordRouteHeader) Request(javax.sip.message.Request) SIPRequest(gov.nist.javax.sip.message.SIPRequest) SipURI(javax.sip.address.SipURI) ListeningPoint(javax.sip.ListeningPoint) InvalidArgumentException(javax.sip.InvalidArgumentException) ParseException(java.text.ParseException) CacheException(org.jboss.cache.CacheException) SipException(javax.sip.SipException)

Aggregations

MessageExt (gov.nist.javax.sip.message.MessageExt)8 ListeningPoint (javax.sip.ListeningPoint)7 ParseException (java.text.ParseException)6 SipException (javax.sip.SipException)6 SIPRequest (gov.nist.javax.sip.message.SIPRequest)5 InvalidArgumentException (javax.sip.InvalidArgumentException)5 Request (javax.sip.message.Request)5 CacheException (org.jboss.cache.CacheException)5 RequestEventExt (gov.nist.javax.sip.RequestEventExt)4 ClientTransaction (javax.sip.ClientTransaction)3 RecordRouteHeader (javax.sip.header.RecordRouteHeader)3 RouteHeader (javax.sip.header.RouteHeader)3 ResponseEventExt (gov.nist.javax.sip.ResponseEventExt)2 Dialog (javax.sip.Dialog)2 SipURI (javax.sip.address.SipURI)2 ServerTransaction (javax.sip.ServerTransaction)1 CSeqHeader (javax.sip.header.CSeqHeader)1 CallIdHeader (javax.sip.header.CallIdHeader)1 ContactHeader (javax.sip.header.ContactHeader)1 ContentLengthHeader (javax.sip.header.ContentLengthHeader)1